Show Posts
Pages: 1 [2] 3 4 ... 9
16  Using Arduino / Programming Questions / Re: RFID module software serial + serial read on: June 15, 2013, 02:18:56 pm
Thanks, Arrch.

I had..."reevaluated my problems" (yes?) and followed your...suggestions...

no luck.

17  Using Arduino / Programming Questions / Re: RFID module software serial + serial read on: June 15, 2013, 01:11:34 pm
Thanks, John.

I have tried your suggestion without anything printing out in the serial monitor from my condition.
18  Using Arduino / Programming Questions / Re: RFID module software serial + serial read on: June 15, 2013, 01:05:20 pm
done. sorry about that.
19  Using Arduino / Programming Questions / RFID module software serial + serial read on: June 15, 2013, 12:48:55 pm
Greetings all!

Im having a bit of an issue applying a conditional to a value printed in the serial monitor. I have an RFID module found here:

http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_93&products_id=2156

It Arduino source code, and am not having problems with just getting the module to work. As I stated, I am trying to add a conditional that once a specific tag ID is printed in serial monitor (as it is doing), print a message.

code below with my addition commented:

Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //pin2 Rx, pin3 Tx

int CMD[64];
int comlen =0;
int out_flag =0;
String result = String('77 08 92 73'  ,DEC);
int resulting = '4D085C49';
//byte C;



void setup()
{
  Serial.begin(9600);
  mySerial.listen();
  Serial.println("Serial number will be displayed here if a card is detected by the module:\n");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  delay(10);
  mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual
}
void loop() // run over and over
{

  while (Serial.available())
  {
    int a = SerialReadHexDigit();
    //Serial.println(a);
    if(a>=0){
      CMD[comlen] = a;
      comlen++;
    }
    delay(10);
  }

  for(int i=0; i<comlen; i+=2){
    int c = mySerial.write( CMD[i]*16 + CMD[i+1]);



  }
  comlen =0;

  byte C;
  while (mySerial.available()) {
    C = mySerial.read();




    if (C<16) Serial.print("0");
    Serial.print(C ,HEX); //Display the Serial Number in HEX
    //Serial.print(" ");



    out_flag =1;

/////////// MY ADDITION /////////////////////////////

    if(Serial.available())
    {
      C = Serial.read();
      if (C == resulting){

        Serial.println("IM IN");
      }
    }

//////////////////////////////////////////////////
  }

  if (out_flag >0) {
    Serial.println();
    out_flag = 0;
  }

}



int SerialReadHexDigit()
{
  byte c = (byte) Serial.read();
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  else if (c >= 'a' && c <= 'f') {
    return c - 'a' + 10;
  }
  else if (c >= 'A' && c <= 'F') {
    return c - 'A' + 10;
  }
  else {
    return -1;   // getting here is bad: it means the character was invalid
  }
}


thanks ahead of time  smiley-kitty
20  Using Arduino / Programming Questions / Re: PS/2 Control keyboard + Arduino on: April 21, 2013, 12:29:32 am
Yes, with what seems to be class specific functions. I am lacking in knowing the basic class command for numeric/letter
21  Using Arduino / Programming Questions / Re: PS/2 Control keyboard + Arduino on: April 20, 2013, 05:34:46 pm
So, what i want the code to do is when an 'a' is pressed, do this, when 'b' is pressed, do that.

the letters are printing in the serial monitor when struck, but I am having a hard time nesting the read values into conditions.
22  Using Arduino / Programming Questions / PS/2 Control keyboard + Arduino on: April 20, 2013, 04:04:38 pm
Greetings! I am using the PS/2 library found here:

http://playground.arduino.cc/Main/PS2Keyboard

Everything hardware wise works great. I cannot for the life of me figure out how to put the incoming key strokes, specifically for letters to play well with conditional statements.

here is my code attempt..its essentially the same  as the example, slightly modified.

Code:
/*  PS2Keyboard library example
 
  PS2Keyboard now requries both pins specified for begin()

  keyboard.begin(data_pin, irq_pin);
 
  Valid irq pins:
     Arduino Uno:  2, 3
     Arduino Due:  All pins, except 13 (LED)
     Arduino Mega: 2, 3, 18, 19, 20, 21
     Teensy 2.0:   All pins, except 13 (LED)
     Teensy 2.0:   5, 6, 7, 8
     Teensy 1.0:   0, 1, 2, 3, 4, 6, 7, 16
     Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
     Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
     Sanguino:     2, 10, 11
 
  for more information you can read the original wiki in arduino.cc
  at http://www.arduino.cc/playground/Main/PS2Keyboard
  or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
 
  Like the Original library and example this is under LGPL license.
 
  Modified by Cuninganreset@gmail.com on 2010-03-22
  Modified by Paul Stoffregen <paul@pjrc.com> June 2010
*/
   
#include <PS2Keyboard.h>

#include "binary.h"
typedef uint8_t boolean;
typedef uint8_t byte;


const int DataPin = 8;
const int IRQpin =  3; //MUST BE PINS 2 OR 3 IF USING ARDUINO UNO

PS2Keyboard keyboard;
byte a;
int values = 0;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(115200);
  Serial.println("Keyboard Test:");
}

void loop() {
 
  if (keyboard.available()) {
   
   
    // read the next key
    char c = keyboard.read();
    Serial.print(c);
    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");

    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
//    } else {

}


   

  }     // otherwise, just print all normal characters
     
   
 

while(Serial.available()){
 
values = Serial.read();
 
 
  if (values=='a' ){ //
    Serial.println ("entered A");
   
}

}
}

Everything compiles, but Im not sure why this chunk below does not show the print message:

while(Serial.available()){
 
values = Serial.read();
 
 
  if (values=='a' ){ //
    Serial.println ("entered A");


23  Community / Gigs and Collaborations / Re: arduino 433mhz rf transmitter and receiver code on: April 14, 2013, 11:53:05 am
You'd probably want to look at xbees (series 1). If you need assistance with further developing this and don't want to figure it out yourself, I'd offer my help as a contractor. Email is danbertner(@)gmail.com
24  Community / Gigs and Collaborations / Re: doors and windows status detection and sms to phone on: April 06, 2013, 04:06:36 pm
I did an identical project recently. Email me at danbertner(@)gmail(dot)com
25  Using Arduino / Sensors / Re: Two Simultaneous Infrared Sensor Readings on: March 31, 2013, 02:45:28 pm
Code:
/////pin declaration/////////////////

int analog0 = A0;
int analog1 = A1;


int sensor[2] = {analog0, analog1}; //Analog 0 pin
const int red_led = 9; //digital pin 9
const int green_led = 7; //digital pin 7

////////////////////////////////////

boolean bool_var = false;



  int sense_readings;
  int i;


////////averager of 20 values//////////////////
const int numReadings = 20;     //higher the number, more numbers read/averaged. slows program down

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

///////////////////////////////////////////////////


int counter;


void setup(){
 
  Serial.begin(115200); //set your baud rate in arduino serial monitor
  pinMode(red_led, OUTPUT);
  pinMode(green_led, OUTPUT);

}



void loop(){
for (i = 0; i < 2; i++) {
sense_readings = analogRead(sensor[i]);
 
   // Serial.println(sensor[i]);
   
    //int new_val = analogRead(sensor[i]);
    Serial.println(sense_readings);
        delay(300);

}

  }



This seems to print out simultaneously the values of two sensors. Anyone confirm this? it seems fine.
26  Using Arduino / Sensors / Re: Two Simultaneous Infrared Sensor Readings on: March 31, 2013, 02:20:21 pm
revised code:

Code:




/////pin declaration/////////////////

int sensors[] = {A0,A1};
const int red_led = 9; //digital pin 9
//const int yellow_led = 6; //main indicator/digital pin 6
const int green_led = 7; //digital pin 7

////////////////////////////////////

boolean bool_var = false;


int sensor_pins = sensors[2];



////////averager of 20 values//////////////////
const int numReadings = 20;     //higher the number, more numbers read/averaged. slows program down
int readings2[numReadings];      // the readings from the analog input
int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

///////////////////////////////////////////////////


int counter;


void setup(){
  
  Serial.begin(115200); //set your baud rate in arduino serial monitor
  pinMode(red_led, OUTPUT);
 // pinMode(yellow_led, OUTPUT);
  pinMode(green_led, OUTPUT);

}



void loop(){

//led_standby();
sensor_read();

  }

 


  int sensor_read(){
    
    int read_sensor = analogRead(sensor_pins);
  
    digitalWrite(red_led, LOW);
    digitalWrite(green_led, HIGH);
  
  
  for (int counting=0; counting <=20; counting++){ //this is a counter; number 100 inside is adjustable for longer delay
    Serial.print("timer = ");
    Serial.println(counting);
   // subtract the last reading:
   total= total - readings[index];        
  // read from the sensor:  
  readings[index] = read_sensor;
  // add the reading to the total:
  total= total + readings[index];
  // advance to the next position in the array:  
  index = index + 1;                    

  // if we're at the end of the array...
  if (index >= numReadings)              
    // ...wrap around to the beginning:
    index = 0;                          

  // calculate the average:
  average = total / numReadings;        
  // send it to the computer as ASCII digits
  Serial.print("averaged sensor readings  = ");
  Serial.println(average);
Serial.println();  

  delay(200);        // delay in between reads for stability  
  
  

    
    
 while(bool_var ==false && average >= 100){ // The sensor is spaced between the end of the wall by 4ft
  
  digitalWrite(red_led, HIGH);
  digitalWrite(green_led, LOW);
  counting=0;
  bool_var = true;
  break;
  

 
  
 
 

  }
  if (counting ==20 && bool_var==true){
      Serial.println("SEND A SIGNAL TO IP CAMERA");
       digitalWrite(red_led, HIGH);
  digitalWrite(green_led, LOW);
      bool_var=false;
  }
  
    
    
  else if (average <100 && counting ==20){
    
    digitalWrite(red_led, LOW);
  digitalWrite(green_led, HIGH);
        bool_var=false;

}
}

}


still not much luck :/






27  Using Arduino / Sensors / Two Simultaneous Infrared Sensor Readings on: March 31, 2013, 12:09:00 am
Greetings!

I am currently using two infrared distance sensors sold on sparkfun: https://www.sparkfun.com/products/8958

I have a simple sketch measuring a single sensor and some filtering. The second sketch I am trying to incorporate an additional IR sensor by putting the analog pins into an array so I may read both sensors values simultaneously. This is my issue; I am not receiving any value from the additional sensor pin.

I have eliminated basic hardware issues (enough current, working sensors, testing additional sensor+original code, etc) So this issue is purely code.

Here is my sketch thus far:

Code:
/////pin declaration/////////////////

const int sensor[] = {A0,A1}; //Analog 0 pin
const int red_led = 9; //digital pin 9
const int green_led = 7; //digital pin 7

////////////////////////////////////

boolean bool_var = false;



  int sense_readings;
  int i;


////////averager of 20 values//////////////////
const int numReadings = 20;     //higher the number, more numbers read/averaged. slows program down

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

///////////////////////////////////////////////////


int counter;


void setup(){
  
  Serial.begin(115200); //set your baud rate in arduino serial monitor
  pinMode(red_led, OUTPUT);
  pinMode(green_led, OUTPUT);

}



void loop(){
for (i = 0; i < 1; i++) {
sense_readings = analogRead(sensor[i]);
  
    Serial.println(sensor[i]);
}
sensor_read();

  }






int sensor_read(){

  

    
    digitalWrite(red_led, LOW);
  digitalWrite(green_led, HIGH);
  
  
  for (int counting=0; counting <=20; counting++){ //this is a counter; number 100 inside is adjustable for longer delay
  Serial.print("timer = ");
  Serial.println(counting);
    // subtract the last reading:
  total= total - readings[index];        
  // read from the sensor:  
  readings[index] =  sense_readings;    //analogRead(sensor);
  // add the reading to the total:
  total= total + readings[index];      
  // advance to the next position in the array:  
  index = index + 1;                    
  
  // if we're at the end of the array...
  if (index >= numReadings)              
    // ...wrap around to the beginning:
    index = 0;                          

  // calculate the average:
  average = total / numReadings;        
  // send it to the computer as ASCII digits
  Serial.print("averaged sensor readings = ");
  Serial.println(average);
Serial.println();  
  delay(300);        // delay in between reads for stability  
  
  
  
    
    
 while(bool_var ==false && average >= 100){ // The sensor is spaced between the end of the wall by 4ft
  
  digitalWrite(red_led, HIGH);
  digitalWrite(green_led, LOW);
  counting=0;
  bool_var = true;
  break;
  

 
  
 
 

  }
  if (counting ==20 && bool_var==true){
      Serial.println("SEND A SIGNAL TO IP CAMERA");
       digitalWrite(red_led, HIGH);
  digitalWrite(green_led, LOW);
      bool_var=false;
  }
  
    
    
  else if (average <100 && counting ==20){
    
    digitalWrite(red_led, LOW);
  digitalWrite(green_led, HIGH);
        bool_var=false;

}
}

}





28  Community / Gigs and Collaborations / Re: Chicago Area Freelancer on: March 20, 2013, 03:21:07 pm
I'm in Chicago and may be of help.

Refer to my site, danbertner.wordpress.com where you will find my direct contact email in addition to my portfolio.

Please contact me through email and not the Arduino forum.

Cheers!
29  Community / Gigs and Collaborations / Re: Problems implementing Twitter's API v1.1 using OAuth on Arduino on: March 20, 2013, 02:58:55 pm
I have a fully functional setup you're describing on the Raspberry Pi. Here's a link to a demo video of it working :http://vimeo.com/61256196

Email me at: danbertner(@)gmail(dot).com if you need help and want to go in this direction.
30  Using Arduino / Programming Questions / Re: Adafruit Wave shield button press song on: January 29, 2013, 12:03:06 pm
SOLVED.

thanks so much.
Pages: 1 [2] 3 4 ... 9