Loading...
  Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / XBEE Receive Ok, Send problem on: May 20, 2013, 07:06:44 am
I use:
Arduino Leonardo
Arduino Wireless SD Shield
XBEE USB Adapter
Two XBEE S1

Receive from Button State was OK, but no sending (LED turn on/off). What's wrong with code?


Code:
#include <SoftwareSerial.h>

const int buttonPin = 2;
const int ledPin = 13;

int buttonState = 0;

SoftwareSerial xbee (0,1);

void setup() {
  xbee.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop(){
       
  if (xbee.available() >0 )
  {
    char ch = xbee.read();
    if (ch == '1')
    {
      digitalWrite(ledPin, HIGH);
    }
    else if (ch == '0')
    {
      digitalWrite(ledPin, LOW);
    }
  }
  buttonState = digitalRead(buttonPin);
 
  if (buttonState == HIGH) {
    xbee.println("Button pressed!");
    delay(500);
  }
}
   
   
2  Using Arduino / Networking, Protocols, and Devices / XBEE PRO - Error flashing on: May 18, 2013, 05:29:54 am
Hello,

i've 3 XBEE PRO S1 (XBP24-ACI-001 revG). Original Firmware is XBP24

I want flash the Firmware XBP24-B. Howewer, i got error message. Why?

I want set COORDINATOR and ROUTER.

3  Using Arduino / Project Guidance / Re: Lego Roverbot Line Follower: Problem with Serial on: April 26, 2013, 05:07:51 am
Nothing works. I give up!
4  Using Arduino / Project Guidance / Re: Lego Roverbot Line Follower: Problem with Serial on: April 25, 2013, 04:13:25 pm


5  Using Arduino / Project Guidance / Re: Lego Roverbot Line Follower: Problem with Serial on: April 25, 2013, 03:50:06 pm
If i remove while(1), Roverbot turn left around and can stopped it, but not follow the line.

If i set while(1), Roverbot follow the line and can't stopped it.

What the heck????

This sucks!
6  Using Arduino / Project Guidance / Re: Lego Roverbot Line Follower: Problem with Serial on: April 25, 2013, 03:31:22 pm
OMG! This sucks!

http://www.dfrobot.com/wiki/index.php?title=Arduino_Motor_Shield_%28L293%29_%28SKU:_DRI0001%29

http://www.dfrobot.com/wiki/index.php/Line_Tracking_Sensor_for_Arduino_%28SKU:SEN0017%29

Code:
int IN2 = 4;
int EN2 = 5;
int EN1 = 6;
int IN1 = 7;
int VCC = 8;
int GND = 9;  
  
void Motor1(int pwm, boolean reverse) {
  analogWrite(EN1,pwm);
  if(reverse) {
    digitalWrite(IN1,HIGH);  
    }
    else {
      digitalWrite(IN1,LOW);  
    }
}
        
void Motor2(int pwm, boolean reverse) {
  analogWrite(EN2,pwm);
  if(reverse) {
    digitalWrite(IN2,HIGH);
  }
  else {
    digitalWrite(IN2,LOW);
    }
}
        
void setup() {
  int i;
  
  for(i=4;i<=7;i++)
  pinMode(i, OUTPUT);
  pinMode(VCC, OUTPUT);
  pinMode(GND, OUTPUT);
  digitalWrite(VCC, HIGH);  //Line Tracking Sensor for Arduino
  digitalWrite(GND, LOW);   //Line Tracking Sensor for Arduino
 
  Serial.begin(9600);  
  delay(2000);
}
 
 
void loop() {
  char val;
  while(1)
  {
    val=Serial.read();
    if(val!=-1) {
      switch(val) {
        case 'g':
        start_line_follow();
        break;
        
        case 'h':
        stop_line_follow();
        break;
      }
    }
  }
}

void start_line_follow() {
  if (digitalRead(10) == HIGH) {
  Motor1(255, false);
  Motor2(255, true);
 }
 else
 {
  Motor1(255, true);
  Motor2(255, true);
  }
}

void stop_line_follow() {
  Motor1(0, false);
  Motor2(0, false);
 }
7  Using Arduino / Project Guidance / Re: Lego Roverbot Line Follower: Problem with Serial on: April 25, 2013, 01:39:46 pm
This code, I was able to start follow line, but do not stop.

Code:
void start_line_follow() {
  while(1){
  if (digitalRead(10) == HIGH) {
  Motor1(255, false);
  Motor2(255, true);
  }
 else
 {
  Motor1(255, true);
  Motor2(255, true);
 
 }
}
}

void stop_line_follow() {
  Motor1(0, false);
  Motor2(0, false);
   }
8  Using Arduino / Project Guidance / Lego Roverbot Line Follower: Problem with Serial on: April 25, 2013, 12:39:20 pm
Hello all,

i use the Lego Roverbot with Line Tracking Sensor for Arduino


This Code without Serial works, Roverbot follow the black line.
Code:
void loop() {
start_line_follow();
  }

void start_line_follow() {
  if (digitalRead(10) == HIGH) {
  Motor1(255, false);
  Motor2(255, true);
 }
 else
 {
  Motor1(255, true);
  Motor2(255, true);
  return;
 }
}
}

This Code with Serial doesn't works, Roverbot turn left around, but not follow the line.
0 = Stop Line Follow
1 = Start Line Follow

Code:
void loop() {
  if (Serial.available() > 0) {
    incomingData = Serial.read();
   
    if (incomingData == 49) { // ASCII Code for 1
      start_line_follow();
    }
   
    if (incomingData == 48) { // ASCI Code for 0
      stop_line_follow();
    }
  }
}

void start_line_follow() {
  if (digitalRead(10) == HIGH) {
  Motor1(255, false);
  Motor2(255, true);
 }
 else
 {
  Motor1(255, true);
  Motor2(255, true);
  return;
 }
}

void stop_line_follow() {
  Motor1(0, false);
  Motor2(0, false);
  return;
}
9  Using Arduino / LEDs and Multiplexing / Mysterious!!!!! Led Fading on: April 10, 2013, 01:09:57 pm
Code:
int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  }

void loop() {
  for(int fadeValue = 0; fadeValue <= 255; fadeValue++) {
    analogWrite(ledPin, fadeValue);
    delay(5);
  }
  for(int fadeValue = 255; fadeValue >= 0; fadeValue--) {
    analogWrite(ledPin, fadeValue);
    delay(5);
  }
}

Why is ledPin 13 blinking, not fading? I use Arduino UNO R3.


int ledPin = 2; -> Blink
int ledPin = 3; -> Fade
int ledPin = 4; -> Blink
int ledPin = 5; -> Fade
int ledPin = 6; -> Fade
int ledPin = 7; -> Blink
int ledPin = 8; -> Blink
int ledPin = 9; -> Fade
int ledPin = 10; -> Fade
int ledPin = 11; -> Fade
int ledPin = 12; -> Blink
int ledPin = 13; -> Blink


10  Using Arduino / LEDs and Multiplexing / Need help - Buttons + LED blinking on: March 31, 2013, 10:48:45 am


Right button pressed -> Right LED blinking until Right button pressed -> Right LED off
Left button pressed -> Left LED blinking until Left button pressed ->  Left LED off

It's blinking, but not turn off smiley-sad Pls help

Here Code:

Code:
int button_right = 2;
int button_left = 3;
int led_right = 5;
int led_left = 6;

int buttonState_right = 0;
int buttonState_left = 0;

void setup()
{
  pinMode(button_right, INPUT);
  pinMode(button_left, INPUT);
  pinMode(led_right, OUTPUT);
  pinMode(led_left, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  buttonState_right = digitalRead(button_right);
  buttonState_left = digitalRead(button_left);
 
  if (buttonState_right == HIGH) // First Right Button pressed
  {
   Blinking_right(HIGH);
  }
   
  if (buttonState_right == HIGH) // Second Right Button pressed
  {
   while (Blinking_right)
   {
    Blinking_right(LOW);
   }
  }
 
   if (buttonState_left == HIGH) // First Left Button pressed
  {
   Blinking_left(HIGH);
  }
   
  if (buttonState_left == HIGH) // Second Left Button pressed
  {
   while (Blinking_left)
   {
    Blinking_left(LOW);
   }
  }
 }

void Blinking_right(boolean right) {
  digitalWrite(led_right, HIGH);
  delay(300);
  digitalWrite(led_right, LOW);
  delay(300);
}

void Blinking_left(boolean left) {
  digitalWrite(led_left, HIGH);
  delay(300);
  digitalWrite(led_left, LOW);
  delay(300);
}
11  Using Arduino / Motors, Mechanics, and Power / 2A Dual Motor Controller + PWM Problem on: March 29, 2013, 05:18:03 am
Hi,

i have this Motor Controller from DFRobot

http://www.dfrobot.com/index.php?route=product/product&path=51_105&product_id=66#.UVVjrqPQiE8


PWM Value from 0-127 didn't work (LEDs didn't showing)
PWM Value from 128-255 works fine, but running same fast.

How did it?

Here the code.
Code:
int E1 = 13;                       
int M1 = 12;                       
int E2 = 11;
int M2 = 10;
   
   
void setup()
{
    pinMode(E1, OUTPUT);
    pinMode(M1, OUTPUT); 
    pinMode(E2, OUTPUT);
    pinMode(M2, OUTPUT);
    Serial.begin(9600);
}
 
void loop()
{
  int value;
  char val;
  while(1)
  {
    val=Serial.read();
    if(val!=-1)
    {
      switch(val)
      {
        case '1': value=100;  //<------------- PWM didn't work, Motor not running!!!!!!
        break;
       
        case '2': value=255;
        break;
       
        case 's'://stop
        digitalWrite(M1, LOW);
        digitalWrite(E1, LOW); //<------------- Motor Speed
        digitalWrite(M2, LOW);
        digitalWrite(E2, LOW);
        break;
       

        case 'q'://Forward left
        digitalWrite(M1, HIGH);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, LOW);
        digitalWrite(E2, HIGH);
        break;
                   
        case 'w'://Forward
        digitalWrite(M1, HIGH);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, LOW);
        digitalWrite(E2, LOW);
        break;
               
        case 'e'://Forward right
        digitalWrite(M1, HIGH);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, HIGH);
        digitalWrite(E2, HIGH);
        break;
                           
        case 'y'://Backward left
        digitalWrite(M1, LOW);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, LOW);
        digitalWrite(E2, HIGH);
        break;
                               
        case 'x'://Backward
        digitalWrite(M1, LOW);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, LOW);
        digitalWrite(E2, LOW);
        break;
                       
        case 'c':// Backward right
        digitalWrite(M1, LOW);
        analogWrite(E1, value); //<------------- Motor Speed
        digitalWrite(M2, HIGH);
        digitalWrite(E2, HIGH);
        break;
      }
    }
  }




http://www.christian-elektronik.de/
12  Using Arduino / Motors, Mechanics, and Power / Microsoft Visual Basic 2010 Express + Motor on: February 05, 2013, 12:09:00 pm




Hello,

I use Visual Basic 2010 to control my Lego Robot. It works.

How can i change PWM speed Motor while Button click? Slow = 50 ; Fast = 255

Arduino Code http://www.dfrobot.com/wiki/index.php?title=Arduino_Motor_Shield_%28L293%29_%28SKU:_DRI0001%29
Code:
case 'w'://Move ahead
                        Motor1(255,true);  //You can change the speed, such as Motor(50,true)
                        Motor2(255,true);
                         break;



Visual Basic 2010 Code

Code:
Private Sub slowButton_Click(sender As System.Object, e As System.EventArgs) Handles slowButton.Click
        SerialPort1.Write("1")
        slowButton.BackColor = Color.Yellow
        fastButton.BackColor = Color.Transparent
    End Sub

    Private Sub fastButton_Click(sender As System.Object, e As System.EventArgs) Handles fastButton.Click
        SerialPort1.Write("2")
        slowButton.BackColor = Color.Transparent
        fastButton.BackColor = Color.Yellow
    End Sub

Bye DEAF BOY
13  General Category / General Discussion / Arduino Fake from China? on: February 04, 2013, 04:48:02 am
Example XBee Shield
Original: www.libelium.com
Fake: www.libelinm.com

Original: M. Yarza
Fake: M. Yerze

Original: ArduinoXBee
Fake: ArduinoxBee

Original: http://site.gravitech.us/Arduino/XBeeShield/ARD-XBEE_3.jpg

Fake: http://img2.buyincoins.com/sinedya/zigbee-xbBee-module_02.jpg
14  Using Arduino / Project Guidance / Two Byte (Serial) on: February 01, 2013, 03:16:39 am
How can I program 2 bytes?

but not works smiley-sad

if (val == 10){
    digitalWrite(LED1, LOW);
  }
  else if (val == 11)
  {
  digitalWrite(LED1, HIGH);
}


Here Code:
Code:
int LED1 = 9;
int LED2 = 8;
int LED3 = 7;
int LED4 = 6;
int LED5 = 5;
int LED6 = 4;
int LED7 = 3;
int LED8 = 2;

void setup(){
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
  pinMode(LED7, OUTPUT);
  pinMode(LED8, OUTPUT);
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
  digitalWrite(LED4, LOW);
  digitalWrite(LED5, LOW);
  digitalWrite(LED6, LOW);
  digitalWrite(LED7, LOW);
  digitalWrite(LED8, LOW);
}

void loop(){
  while (Serial.available() == 0);
  int val = Serial.read();
  
  //-----------------------------------------------LED1
  if (val == 10){
    digitalWrite(LED1, LOW);
  }
  else if (val == 11)
  {
  digitalWrite(LED1, HIGH);
}

  //-----------------------------------------------LED2
  if (val == 20){
    digitalWrite(LED2, LOW);
  }
  else if (val == 21)
  {
  digitalWrite(LED2, HIGH);
}

  //-----------------------------------------------LED3
  if (val == 30){
    digitalWrite(LED3, LOW);
  }
  else if (val == 31)
  {
  digitalWrite(LED3, HIGH);
}

  //-----------------------------------------------LED4
  if (val == 40){
    digitalWrite(LED4, LOW);
  }
  else if (val == 41)
  {
  digitalWrite(LED4, HIGH);
}

  //-----------------------------------------------LED5
  if (val == 50){
    digitalWrite(LED5, LOW);
  }
  else if (val == 51)
  {
  digitalWrite(LED5, HIGH);
}

  //-----------------------------------------------LED6
  if (val == 60){
    digitalWrite(LED6, LOW);
  }
  else if (val == 61)
  {
  digitalWrite(LED6, HIGH);
}

  //-----------------------------------------------LED7
  if (val == 70){
    digitalWrite(LED7, LOW);
  }
  else if (val == 71)
  {
  digitalWrite(LED7, HIGH);
}

  //-----------------------------------------------LED8
  if (val == 80){
    digitalWrite(LED8, LOW);
  }
  else if (val == 81)
  {
  digitalWrite(LED8, HIGH);
}
else
{
}
  Serial.flush();
}

15  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 - Error compiler on: January 19, 2013, 06:28:45 am
Quote
Which version of the Arduino IDE are you using?
Arduino 1.0.3

now one problem:

In file included from DS1307.cpp:3:
C:\Dokumente und Einstellungen\Keller-PC\Desktop\Arduino\libraries\DS1307/DS1307.h:55: error: 'byte' does not name a type

DS1307.h
Code:

41 // library interface description
42 class DS1307
43 {
44  // user-accessible "public" interface
45  public:
46    DS1307();
47    void get(int *, boolean);
48    int get(int, boolean);
49 void set(int, int);
50    void start(void);
51    void stop(void);
52
53  // library-accessible "private" interface
54  private:
55    byte rtc_bcd[7]; // used prior to read/set ds1307 registers;
56 void read(void);
57 void save(void);
58 };
Pages: [1] 2