Help With The Spaceship Interface


hey guys.
i'm following through arduino projects book learn board.

i'm having problems project 02, spaceship one. think i've got code right, , wiring correct. red lights mean't flash when button pressed, , green led lights when isn't pressed. in version or without button pressed red lights flash.

the code says input on pin 2, , if low green led lights, if high red leds flash. mean current flowing pin 2 in scenario (the red leds flash). if disconnect wire pin 2 red leds still flash.

i've attached pic of circuit , breadboard

here code:

int switchstate = 0;
void setup(){
  pinmode(3,output);
  pinmode(4,output);
  pinmode(5,output);
  pinmode(2,input);
}
void loop (){
  switchstate = digitalread(2);
  // comment

  if (switchstate = low)  {
    // button isn't pressed


    digitalwrite(3, high) ;   //  green led
    digitalwrite(4, low) ;    //  red led
    digitalwrite(5, low) ;    //  red led
  }

  else  {  //the button pressed
    digitalwrite(3, low) ;
    digitalwrite(4, low) ;
    digitalwrite(5, high) ;



    delay(250) ;   // wait quarter second
    //  toggle leds
    digitalwrite(4, high) ;
    digitalwrite(5, low) ;
    delay(250) ; // wait quarter second

  }
}  //  go beginning of loop

oops:
code: [select]
  if (switchstate = low)  {

needs == instead.


Arduino Forum > Using Arduino > Project Guidance > Help With The Spaceship Interface


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support