110 likes | 259 Views
Good LED Circuit. 5V0. GND. What Voltage Does Meter See?. Answer: 5 V. What Voltage Does Meter See?. Answer: 0 V. R is a pull-down resistor. What Voltage Does Meter See?. Answer: 0 V. What Voltage Does Meter See?. Answer: 5 V. R is a pull-up resistor.
E N D
Good LED Circuit 5V0 GND
What Voltage Does Meter See? Answer: 5 V
What Voltage Does Meter See? Answer: 0 V R is a pull-down resistor
What Voltage Does Meter See? Answer: 0 V
What Voltage Does Meter See? Answer: 5 V R is a pull-up resistor
Program to Turn on LED /* Set Pin 25 (ledPin) to HIGH. */ intledPin = 25;// Label Pin 25 ledPin. void setup() { // setup() runs once. pinMode(ledPin, OUTPUT); // Set ledPin for output. } void loop() {// loop() runs "forever". digitalWrite(ledPin, HIGH);// Set ledPin HIGH. }
Button-Controlled LED /* Set Pin 25 (ledPin) to HIGH if Pin 4 (buttonPin) is HIGH. Otherwise set Pin 25 to LOW. */ intledPin = 25; // Label Pin 25 ledPin. intbuttonPin = 4; // Label Pin 4 buttonPin. void setup() { // setup() runs once. pinMode(buttonPin, INPUT); // Set buttonPin for input. pinMode(ledPin, OUTPUT); // Set ledPin for output. } void loop() { // loop() runs "forever". // Check if buttonPin is HIGH. if (digitalRead(buttonPin) == HIGH) { digitalWrite(ledPin, HIGH); // Set ledPin HIGH. } else { digitalWrite(ledPin, LOW); // Set ledPin LOW. } }
Button-Controlled (Blinking) LED /* Alternate Pin 25 (ledPin) between HIGH and LOW every half second if Pin 4 (buttonPin) is HIGH. Otherwise set Pin 25 to LOW. */ intledPin = 25; // Label Pin 25 ledPin. intbuttonPin = 4; // Label Pin 4 buttonPin. void setup() { // setup() runs once. pinMode(buttonPin, INPUT); // Set buttonPin for input. pinMode(ledPin, OUTPUT); // Set ledPin for output. } void loop() { // loop() runs "forever". // Check if buttonPin is HIGH. if (digitalRead(buttonPin) == HIGH) { digitalWrite(ledPin, HIGH); delay(500); // Wait a half second. digitalWrite(ledPin, LOW); delay(500); // Wait another half second. } else { digitalWrite(ledPin, LOW); } }