Download presentation
Presentation is loading. Please wait.
Published byAshley Franklin Modified over 9 years ago
1
Good LED Circuit 5V0 GND
2
What Voltage Does Meter See? Answer: 5 V
3
What Voltage Does Meter See? Answer: 0 V R is a pull-down resistor
4
What Voltage Does Meter See? Answer: 0 V
5
What Voltage Does Meter See? Answer: 5 V R is a pull-up resistor
6
chipKit Sense Switch & Control LED
8
/* Set Pin 25 (ledPin) to HIGH. */ int ledPin = 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. } Program to Turn on LED
9
/* Set Pin 25 (ledPin) to HIGH if Pin 4 (buttonPin) is HIGH. Otherwise set Pin 25 to LOW. */ int ledPin = 25; // Label Pin 25 ledPin. int buttonPin = 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 LED
10
/* Alternate Pin 25 (ledPin) between HIGH and LOW every half second if Pin 4 (buttonPin) is HIGH. Otherwise set Pin 25 to LOW. */ int ledPin = 25; // Label Pin 25 ledPin. int buttonPin = 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); } Button-Controlled (Blinking) LED
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.