Thursday 16 March 2017

Arduino Starter Kit - Project 2 - Spaceship Interface

Spaceship Interface

The  Youtube video by Massimo Banzi, one of the Co-Founders of Arduino, introduces the Spaceship Interface


Building

I built the circuit first based on the Arduino Starter Kit Project 2. The completed board is shown below. This time I transferred Project2 circuit into Autodesk Circuits to simulate and test it. Project2 in Autodesk Circuits can be seen in on YouTube.

The Constructed Breadboard

Constructed in Autodesk Circuits

Breadboard and Schema through Fritzing

Project 2 - Breadboard in Fritzing

Project 2 - Schema in Fritzing

Code

int switchState = LOW;
const int greenLED = 3;
const int redLED1 = 4;
const int redLED2 = 5;

const int waitTime = 2000;  // ms

//configures the digital pins
void setup() {
  pinMode(greenLED, OUTPUT);
  pinMode(redLED1, OUTPUT);
  pinMode(redLED2, OUTPUT);
  pinMode(2, INPUT);
}

//Checks the voltageo of the digital input and chooses the pin for voltage ( pin 2 )
void loop() {
  switchState = digitalRead(2);

  if (switchState == LOW) {
    //Button is not pressed

    digitalWrite(greenLED, HIGH); //Green LED
    digitalWrite(redLED1, LOW); //Red LED
    digitalWrite(redLED2, LOW); //red LED
  }

  else { //the button is pressed
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED1, LOW);
    digitalWrite(redLED2, HIGH);

    delay(2000); //wait for a quarter second
    //toggle the LEDs
    digitalWrite(redLED1, HIGH);
    digitalWrite(redLED2, LOW);
    delay(2000); //wait for a quarter second
  }
} //go back to the beginning of the loop

Results


The circuit worked and the LED lit as predicted.

  • Voltage drop across green diode 1.99V
  • Voltage drop across green LED resistor 1.94V
  • Voltage drop across red LED resistor 1.99V

No comments:

Post a Comment