Project No.2 in the Arduino Starter Project Book is right!

It was my ethernet shield. it was damaged, i think. when i remove the shield it work fine.
Thanks guys. On to the next project.I love arduinos.

Can you expand on that?
(I don't have the book, so can't check)

2 Likes

Is that "this little detail is wrong", or "they put the wrong picture on the wrong page", or "the caption says red, but the wire is green".

Bummer!

And what are your expectations now?

I think you need to copy your code here* , my crystal ball suggests you have a missing or extra { ( or})

  • most of us don’t have the book and/ or are responding from a phone so can’t access it

Hint already posted shows that this variable has different capitalization between declaration and use. A no-no in C, C++.

Lol. So about 9 years ago I bought my first Arduino off the shelf of a then not yet defunct Radio Shack. Back then a starter kit was an Uno, a few LEDs and some jumper wires. They came with a book called "Getting Started with Arduino."

It was utter trash - mostly half baked philosophy.

I guess they have not improved a lot, lol.

In the IDE window
File>Examples>10StarterKitBasicKit>p02_SpaceshipInterface.ino
Compiles without issue.
Is what is printed in the book different code?

/*
  Arduino Starter Kit example
  Project 2 - Spaceship Interface

  This sketch is written to accompany Project 2 in the Arduino Starter Kit

  Parts required:
  - one green LED
  - two red LEDs
  - pushbutton
  - 10 kilohm resistor
  - three 220 ohm resistors

  created 13 Sep 2012
  by Scott Fitzgerald

  https://store.arduino.cc/genuino-starter-kit

  This example code is part of the public domain.
*/

// Create a global variable to hold the state of the switch. This variable is
// persistent throughout the program. Whenever you refer to switchState, you’re
// talking about the number it holds
int switchstate = 0;

void setup() {
  // declare the LED pins as outputs
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  // declare the switch pin as an input
  pinMode(2, INPUT);
}

void loop() {

  // read the value of the switch
  // digitalRead() checks to see if there is voltage on the pin or not
  switchstate = digitalRead(2);

  // if the button is not pressed turn on the green LED and off the red LEDs
  if (switchstate == LOW) {
    digitalWrite(3, HIGH);  // turn the green LED on pin 3 on
    digitalWrite(4, LOW);   // turn the red LED on pin 4 off
    digitalWrite(5, LOW);   // turn the red LED on pin 5 off
  }
  // this else is part of the above if() statement.
  // if the switch is not LOW (the button is pressed) turn off the green LED and
  // blink alternatively the red LEDs
  else {
    digitalWrite(3, LOW);   // turn the green LED on pin 3 off
    digitalWrite(4, LOW);   // turn the red LED on pin 4 off
    digitalWrite(5, HIGH);  // turn the red LED on pin 5 on
    // wait for a quarter second before changing the light
    delay(250);
    digitalWrite(4, HIGH);  // turn the red LED on pin 4 on
    digitalWrite(5, LOW);   // turn the red LED on pin 5 off
    // wait for a quarter second before changing the light
    delay(250);
  }
}

Just use the examples in the arduino IDE


Do we have to put resistors through ground connections? Isn't it the other way around, resistors before the LEDs? When i connect the pins 2,3,4,5, it does'nt work but when i switch to 13,12,11 and 10, it works fine? Is there a defect in my board? I brought the Arduino Starter kit, its quiet costly.... :disappointed_relieved:

Please reply. Thx.

I think the wiring is wrong???

Don´t think - check and make !

I'm doing it. I making it. Dude. Just check my post. If you could help me out. I will be very grateful. Thanks.

is there a defect in my board?

It does not matter at which side the resistor is.

Can you show a clear picture of your physical setup.

Did you miss the first chapters how to connect led´s, resistor´s etc??

The first project uses the 5v and GND pins. I did everything as in the book. Works fine. The second project uses pin 2,3,4,5, i did it,it does,nt work. I switch the pins to 13,12,11,10 and it works fine.

Resistors: OK thanks.
Picture: I dont have it right now.
Is there a way to check if my pins (2,3,4,5,6,7) are working? Pins(13-8) are working fine.
Thx