Spaceship Interface
The Youtube video by Massimo Banzi, one of the Co-Founders of Arduino, introduces the Spaceship Interface
- Arduino's digital pins can act as both input and outputs
- Pins 0, 1 are used for communication with the computer, so start at pin 2. On the board is marked as TX, RX I guess transmit and receive.
- I need to study pull-up and pull-down resistors.
- A simple introduction to the pulldown resistor is given in the Lab: Digital Input and Output with an Arduino
- From Arduino on Pull Up and Pull Down Resistors and additionally this.
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