Show Posts
Pages: 1 2 3 [4]
46  Using Arduino / Programming Questions / Re: need help on: February 05, 2011, 09:28:58 pm
ok i still get error here is the new one

/*
 
 
 4 inputs with with (and &&) and 2 outputs
 

 */
 
// set pin numbers:
 int rredPin1 = 2;      /*come in from rovio
 int rblackPin2 = 3;     *
 int lredPin3 = 4;       *
 int lblackPin4 = 5;     *
 int fwheelPin =  10;      // out to wheels
 int rwheelpin =  8;
// variables will change:
int rredState1 = 0;         /* variable for reading rovio status
int rblackState2 = 0;        *
int lredState3 = 0;          *
int lblackState4 = 0;        */
void setup() {
   // initialize the pin as an output and input
  pinMode(10, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(2, INPUT);     
}

void loop(){
  // read rovio input
  rredState1 = digitalRead(rredPin1);
  rblackState2 = digitalRead(rblackPin2);
   lredState3 = digitalRead(lredPin3);
   lblackState4 = digitalRead(lblackPin4);
 
  // if it is, then it is high
  if (rredState1 == HIGH && rblackState2 == HIGH){
   
    // turn LED on:   
    digitalWrite(fwheelPin, HIGH);
  }
  else {
     // turn LED off:
    digitalWrite(fwheelPin1, LOW); 
  }

 
 
  if (lredState3 == HIGH && lblackState4 == HIGH) {     
    // turn LED on:       
    digitalWrite(rwheelPin, HIGH);
  }
  else {
   
    digitalWrite(rwheelPin, LOW);
  }
}









bobo_bot_wont_work.cpp: In function 'void loop()':
bobo_bot_wont_work:32: error: 'rredState1' was not declared in this scope
bobo_bot_wont_work:33: error: 'rblackState2' was not declared in this scope
bobo_bot_wont_work:33: error: 'rblackPin2' was not declared in this scope
bobo_bot_wont_work:34: error: 'lredState3' was not declared in this scope
bobo_bot_wont_work:34: error: 'lredPin3' was not declared in this scope
bobo_bot_wont_work:35: error: 'lblackState4' was not declared in this scope
bobo_bot_wont_work:35: error: 'lblackPin4' was not declared in this scope
bobo_bot_wont_work:41: error: 'fwheelPin' was not declared in this scope
bobo_bot_wont_work:45: error: 'fwheelPin1' was not declared in this scope
bobo_bot_wont_work:52: error: 'rwheelPin' was not declared in this scope
bobo_bot_wont_work:56: error: 'rwheelPin' was not declared in this scope
47  Using Arduino / Programming Questions / Re: need help on: February 05, 2011, 06:58:21 pm
it is o/5volt (low/high) coming out of rovio.I am just learning how to do this,i can program ladder logic very well but this is all new.i am not sure what this means i will look it up   << do not add the ' =10' here
as for names i was trying to keep it simple while i am learning. thanks for help any more advise will be very helpful
tom
48  Using Arduino / Programming Questions / need help on: February 05, 2011, 04:39:54 pm
Hi,i just started learning how to write code and don't know where i am going wrong.I do good until i add 4 inputs,what do you all think
thanks tom

/*
 
4 inputs with with (and &&) and 2 outputs
 
 

 */


// set pin numbers:
 int buttonPin1 = 2;   /*come in from rovio 
 int buttonPin2 = 3;    * 
 int buttonPin3 = 4;    *
 int buttonPin4 = 5;   */
 int ledPin =  10;      // out to wheels
 int ledpin =  8;       //out to wheels
// variables will change:
int buttonState1 = 0;         /* variable for reading rovio status
int buttonState2 = 0;          *
int buttonState3 = 0;          *
int buttonState4 = 0;          */
void setup() {
  // initialize the pin as an output and input
  pinMode(10, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(2, INPUT);     
}

void loop(){
  // read rovio input
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
 
  // if it is, then it is HIGH:
  if (buttonState1 == HIGH && buttonState2 == HIGH){
   
    // turn LED on:   
    digitalWrite(ledPin = 10, HIGH);
  }
  else {
     // turn LED off:
    digitalWrite(ledPin = 10, LOW); 
  }

 
 
  if (buttonState3 == HIGH && buttonState4 == HIGH) {     
    // turn LED on:       
    digitalWrite(ledPin = 8, HIGH); //turn led on
  }
  else {
   
    digitalWrite(ledPin = 8, LOW);
  }
}
Pages: 1 2 3 [4]