Pages: [1]   Go Down
Author Topic: what did i do wrong  (Read 406 times)
0 Members and 1 Guest are viewing this topic.
scranton,pa
Offline Offline
Newbie
*
Karma: 2
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok her goes  I have a rovio robot and am trying to make it a 4x4 for out doors,i now have +5volts on input that come from rovio wheels going into arduino inputs and the out put pins going to rc 4x4. Now my problem is i have +5 to +6 volts at the pin inputs but am only getting +2.45volts out for the fwheelpin and rwheelpin put,lturn and rturn i get +5volts on all out put pins like i should and does run the wheels on rc 4x4. is there something wrong wih my program? i tried 2 different ones and same problem.
Code:
/*
                                      program 1
 
 
 4 inputs with with (and &&) and 2 outputs
 

 */
 
// set pin numbers:
 int redpin = A3;      // 2red come in from rovio
 int bluepin = A2;    // 3blue
 int blackpin = A1;     // 4black  
 int greenpin = A0;   // 5green  
 int fwheelpin =  2;      // out to wheels
 int rwheelpin =  4;
 int lturn = 7;
 int rturn = 8;
// variables will change:
int redState = 0;         // variable for reading rovio status
int blueState = 0;        
int blackState = 0;          
int greenState = 0;        
void setup() {
   // initialize the pin as an output and input
  pinMode(8, OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(2,OUTPUT);
  pinMode(A3, INPUT);
  pinMode(A2, INPUT);
  pinMode(A1, INPUT);
  pinMode(A0, INPUT);
    
}

void loop(){
  // read rovio input
  redState = analogRead(redpin);
  blueState = analogRead(bluepin);
   blackState = analogRead(blackpin);
   greenState = analogRead(greenpin);
  
  // forward, then it is high
  if (redState >100 && greenState >100){  
    
    // turn LED on:    
    digitalWrite(fwheelpin, HIGH);
 
  }
  else {
     // turn LED off:
    digitalWrite(fwheelpin, LOW);  
  }
  // revers high
  if (blueState >350 && greenState >350){
    
    //turn on
    digitalWrite(rwheelpin,HIGH);
  }

  else{
    //turn off
    digitalWrite(rwheelpin,LOW);
  }

  //turn left
  if (redState >350 && blackState >350){
    digitalWrite(rwheelpin,HIGH);
    digitalWrite(lturn,HIGH);
    
  }
  else{
     digitalWrite(rwheelpin,LOW);
      digitalWrite(lturn,LOW);
}
  //turn right
  if(blueState >200 && greenState >200){
    digitalWrite(fwheelpin,HIGH);
    digitalWrite(rturn,HIGH);
    
  }
  else{
     digitalWrite(fwheelpin,LOW);
      digitalWrite(rturn,LOW);
}
}


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

 */
 
// set pin numbers:
 int redpin = 2;      //come in from rovio
 int bluepin = 3;    
 int blackpin = 4;      
 int greenpin = 5;    
 int fwheelpin =  8;      // out to wheels
 int rwheelpin =  9;
 int lturn = 10;
 int rturn = 7;
// variables will change:
int redState = 0;         // variable for reading rovio status
int blueState = 0;        
int blackState = 0;          
int greenState = 0;        
void setup() {
   // initialize the pin as an output and input
  pinMode(10, OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(2, INPUT);
    
}

void loop(){
  // read rovio input
  redState = digitalRead(redpin);
  blueState = digitalRead(bluepin);
   blackState = digitalRead(blackpin);
   greenState = digitalRead(greenpin);
  
  // if it is, then it is high
  if (redState == HIGH && greenState == HIGH){  
    
    // turn LED on:    
    digitalWrite(fwheelpin, HIGH);
 
  }
  else {
     // turn LED off:
    digitalWrite(fwheelpin, LOW);  
  }

 
  if (blueState == HIGH && greenState == HIGH) {    
    // turn LED on:      
    digitalWrite(rwheelpin,HIGH);

  }
  else {
    
    digitalWrite(rwheelpin,LOW);
  }
  //turn left
  if(redState == HIGH && blackState == HIGH){
    digitalWrite(rwheelpin,HIGH);
    digitalWrite(lturn,HIGH);
    
  }
  else{
     digitalWrite(rwheelpin,LOW);
      digitalWrite(lturn,LOW);
}
  //turn right
  if(blueState == HIGH && greenState == HIGH){
    digitalWrite(fwheelpin,HIGH);
    digitalWrite(rturn,HIGH);
    
  }
  else{
     digitalWrite(fwheelpin,LOW);
      digitalWrite(rturn,LOW);
}
}
 
 
Logged

Rosario, Argentina
Offline Offline
Newbie
*
Karma: 1
Posts: 47
Ye olde electronics school
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

read my answers on your other thread, btw: do not put both programs under a single Code tag  smiley
Logged

scranton,pa
Offline Offline
Newbie
*
Karma: 2
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok thanks
Logged

Pages: [1]   Go Up
Jump to: