Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: Xbee Series s2 + arduno uno simple communication on: July 12, 2014, 03:08:10 am
Finally,my hand gesture controlled robot works!
Here's a video: https://vimeo.com/100544353
Soon there will be a instructable for it as well
2  Using Arduino / Networking, Protocols, and Devices / Re: Xbee Series s2 + arduno uno simple communication on: July 02, 2014, 03:08:26 pm
Quote
But your suggestion is not to have any of the arduinos hooked up to the computer while these two are communicating between each other?
You'll have a hard time debugging anything that way. It was more of a hint for you to tell us how the XBees are connected to the Arduinos.

Really strange behavior when I tried to read from serial from the Xbee but finally I solved it..
I realized that along with the integers I sent the Xbee somehow read alot of other junk. Just by one reading from the serial buffer this lines popped up:
126
0
16
144
0
19
162
0
64
113
166
165
201
192
1
49
48
48
48
115

Anyway, before I sent my message,on the router-side I sent only one character "s", to indicate the start for my "message", and on the coordinator-side if the first thing in the buffer is an "s", then I read the whole incoming message. Code is below if anyone is intrested or have any similar problems.
 My purpose with this project was to be able to control four different led's with Xbee communication and a glove with flexsensors on.

Router-side:
int flexSensorPin1 = A0;
int flexSensorPin2 = A1;
int flexSensorPin3 = A2;
int flexSensorPin4 = A3;
char s_str1[2];
char s_str2[2];
char s_str3[2];
char s_str4[2];
String str1,str2,str3,str4;
void setup(){
  Serial.begin(9600);
}

void loop(){
 int flexS1 = analogRead(flexSensorPin1);
 int flexS2 = analogRead(flexSensorPin2);
 int flexS3 = analogRead(flexSensorPin3);
 int flexS4 = analogRead(flexSensorPin4);

if (flexS1 < 620) flexS1 = 620;
else if (flexS1 > 690) flexS1 = 690;
if (flexS2 < 390) flexS2 = 390;
else if (flexS2 > 450) flexS2 = 450;
if (flexS3 < 580) flexS3 = 580;
else if (flexS3 > 710) flexS3 = 710;
if (flexS4 < 640) flexS4 = 640;
else if (flexS4 > 690) flexS4 = 690;

  int flex_1_0to100 = map(flexS1, 690, 620, 9, 0); 
  int flex_2_0to100 = map(flexS2, 450, 390, 9, 0);
  int flex_3_0to100 = map(flexS3, 710, 580, 9, 0);
  int flex_4_0to100 = map(flexS4, 690, 640, 9, 0);
 
  str1=String(flex_1_0to100);
  str1.toCharArray(s_str1,2);
 
  str2=String(flex_2_0to100);
  str2.toCharArray(s_str2,2);
 
  str3=String(flex_3_0to100);
  str3.toCharArray(s_str3,2);
 
  str4=String(flex_3_0to100);
  str4.toCharArray(s_str4,2);

  Serial.print("s");
  Serial.print(s_str1);
  Serial.print(s_str2);
  Serial.print(s_str3);
  Serial.print(s_str4);

  delay(100);
}


Coordinator-side
// Coordinator!
int ledPins[]={9,10,11,12};
int l_pin=sizeof(ledPins);


void setup()
{
 
  for (int i=0;i<l_pin;i++){
  pinMode(ledPins, OUTPUT); 
  }
  Serial.begin(9600);
}

void loop()
{
 
  if (Serial.available() >=5 ) {
    // read the oldest byte in the serial buffer:
   char incomingByte1 = Serial.read();
   char incomingByte2 = Serial.read();
   char incomingByte3 = Serial.read();
   char incomingByte4 = Serial.read();
   char incomingByte5 = Serial.read();

 //  Serial.flush();
   
   if(incomingByte1=='s'){
   int val_1 = incomingByte2-'0';
   int val_2 = incomingByte3-'0';
   int val_3 = incomingByte4-'0';
   int val_4 = incomingByte5-'0';
      Serial.println(val_1);
      Serial.println(val_2);
      Serial.println(val_3);
      Serial.println(val_4);
      Serial.println();
   if(val_1==0){
     analogWrite(ledPins[0],HIGH);
   }
   else{
     analogWrite(ledPins[0],LOW);
   }
   
    if(val_2==0){
     analogWrite(ledPins[1],HIGH);
   }
   else{
     analogWrite(ledPins[1],LOW);
   }
   
    if(val_3==0){
     analogWrite(ledPins[2],HIGH);
   }
   else{
     analogWrite(ledPins[2],LOW);
   }
   
   if(val_4==0){
     analogWrite(ledPins[3],HIGH);
   }
   else{
     analogWrite(ledPins[3],LOW);
   }
  }
 
  }
  delay(10);
}
3  Using Arduino / Networking, Protocols, and Devices / Re: Xbee Series s2 + arduno uno simple communication on: June 25, 2014, 06:01:19 am
It didnt work. But your suggestion is not to have any of the arduinos hooked up to the computer while these two are communicating between each other?
4  Using Arduino / Networking, Protocols, and Devices / Re: Xbee Series s2 + arduno uno simple communication on: June 25, 2014, 05:47:27 am
ok! right now my coordinator is hooked up to the computer via a usb-cable to get power and my router is hooked up to an extarnal powersupply. I will change that and see if it works the other way
5  Using Arduino / Networking, Protocols, and Devices / Xbee Series s2 + arduno uno simple communication on: June 25, 2014, 05:26:38 am
Hi!

I've configured my Xbee and ardunio and got this simple communication program working:
// This code is for the router!

Router:
void setup()
{
  Serial.begin(9600);
}
void loop()
{
    //Send to coordinator: "0"
    Serial.println("0");
    delay(1000);
    //Send to coordinator: "1"
    Serial.println("1");
    delay(1000);   
}

Coordinator:
void setup() {
  Serial.begin(9600);
   pinMode(ledPin, OUTPUT);
}


void loop() {

  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte == '1') {
      digitalWrite(ledPin, HIGH);
    }
    // if it's an 0 turn off the LED:
    if (incomingByte == '0') {
      digitalWrite(ledPin, LOW);
    }
  }


But instead of sending a character I want to send an integer which I get from some analog sensors, but when the coordinator recives this its just dont work and it recievs multiple lines of integers.

I also followed this one: http://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand-1/step5/The-Code/
And instead of sending an integer its sending a byte for each value from the sensor, but its the same there, my coordinator recives multiple lines of numbers which is completly irrelevant.

Anyone who knows where the problem lies?
6  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 22, 2012, 05:38:36 pm
Finally! Thanks for all help! Really appreciate it:D
7  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 22, 2012, 10:14:56 am
And here is the code :

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello arduino.cc!");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis()/1000);
8  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 22, 2012, 10:12:36 am
Ok. Now I've got a brand new display. Ive solder a header on it, then made the right connections. Anyway the LCD's backlight wont light up.
And yes I have tried from the beginning with resistors. I've started on 680 ohm resistor and then went down to a 560,470,390,330,270,180,150 and now a 100 ohm, still this stupid backlight wont show up.
Here's a pic with little more Christmasfeeling..


Now when I thougt of it.. When I had my old display and the wrong connections the backlight went up at least.
Like here: https://vimeo.com/54704282
Something is very mysterious with this special lcd.
Seems like the LCD from usa on ebay is much more easy than this model.
http://www.ebay.com/itm/1pcs-1602-16x2-HD44780-Character-LCD-Display-Module-LCM-blue-blacklight-New-/281040213404?pt=LH_DefaultDomain_0&hash=item416f4d559c

9  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 07, 2012, 03:38:49 pm
Ok, I got the contrast working now, I can se the bars.. But to get the volts down to 4,2 on my pin 15, I needed a 560K resistor... And when I got that volt it didnt light up.
So I think my backlight must have been broken.
10  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 04, 2012, 03:50:15 pm
I found a similiar LCD (if its not the same) , with exactly the same boarddesign, and numbers of the pins : http://www.produktinfo.conrad.com/datenblaetter/175000-199999/181664-da-01-en-LCD_MODUL_STN_POSITIV_LED_WEISS_16X2.pdf

Anyway, when I wired only the VSS and the VDD from the LCD to my arduino (just making sure the LCD worked) it didnt come alive, not a sign, so, I suppose it must be broken.
11  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 04, 2012, 06:26:35 am
Ok, I think this is kind of embarrassing..

I havent noticed the pinmarks on the backside of the lcd, because the gudie I followed was for just the same lcd.

But here is a pic of the backside of my lcd : http://oi46.tinypic.com/30tqeio.jpg

Is it true that the first pin to the left is my number 15 and next is 16?
Because I thougt the very first pin to the left was my pin number 1.
12  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 02, 2012, 12:07:57 pm
Quote
I've recently tested to connect the backlight to the 3v pin on the arduino instead.
Regardless of how you power an LED you still need some way to limit the current and this almost always involves the use of a resistor. 

Depending upon the LED configuration in the backlight circuit the 3 V supply may not provide enough voltage and/or current to work properly.

You should power the backlight from a 5 Volt supply using a resistor in between the supply and one of the backlight pins.  Unfortunately your data sheet does not supply enough information to determine the required resistance so you will have to experiment.  I would start out with about 150 ohms and see if the voltage across the LED is then within specifications and if the backlight is sufficiently bright.


Quote
Could I have destoyed the backlight when I wired it to the +5V?
You didn't help it or the Arduino power supply at all, but you probably didn't destroy either of them (yet) either.
 
Don

Thanks for the help so far!!
Will buy everything tomorrow, and come back with the result.
13  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 02, 2012, 11:49:15 am
Quote
Here is a clearly pic of how I wired everything...

Look in the lower left box in the 'Description of Terminals' and you will see that the backlight must be supplied with no more than 4.5 Volts.

This means that you must use a series resistor to drop the voltage and at the same time limit the current through tbe LED backlight.


Don

I've recently tested to connect the backlight to the 3v pin on the arduino instead. But its the same. (Ive solder the wires on the backside of the LCD)
Could I have destoyed the backlight when I wired it to the +5V?

Will buy the headers tomorrow and solder it.
14  Using Arduino / Displays / Re: 16x2 lcd with UnoR3 probs on: December 02, 2012, 08:18:23 am
When I checked the potentiometer,I used a voltmeter and looked at the output voltage when the arduino was running and only coupled in the voltage from the arduino.I think the potentiometer works because it gives diffrent voltage to the LCD. It also changes the contrast a liiiiiitle liiiitle bit.
Little bit hard to see it in the video tho.
Here is the video: https://vimeo.com/54703995

Here is a clearly pic of how I wired everything, and a pic I got from the manual to compare with.
http://tinypic.com/view.php?pic=2ldubtt&s=6

Here is a video showing how the white boxes flashes when I turned the potentiometer with everything wired:
https://vimeo.com/54704282

Here is the manual for the LCD from the manufactor:
http://www.kjell.com/.mvc/Document/File?id=b6e33422-63ff-48be-b140-a04a0114d7ef

And here is the code I was runnning with everyting coupled in the pic:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis()/1000);
}


15  Using Arduino / Displays / 16x2 lcd with UnoR3 probs on: December 01, 2012, 03:44:16 pm
Hi!

It seems I got the famous problem with the lcd. The letters wont appear.
Its a 16x2 blue lcd.

Have checked the cables over and over again and I find it correct.
The LCD starts and the backlight shows, but not the letters.
Sometimes the white boxes flashes a millisec or so, then disappears.

Im followed the Hello world guide wich comes with the arduino.
I got the 10K potentiometer. And I have tried with and without it, same result.
I also cant change the contrast with the potentiometer coupled on. Ive
checked the outputvoltage on it,and it works!
Anybody that got an idea? Can link a video if someone want a look.
Pages: [1]