RGB LEDs.

Slides:



Advertisements
Similar presentations
temperature system wiring
Advertisements

Using the servo library living with the lab Libraries are computer programs written to add functionality to Arduino programs. A library to control hobby.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Waterproofing a thermistor ENGR 121 living with the lab © 2013 David Hall.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
User-defined functions in Arduino sketches living with the lab © 2012 David Hall.
Using Your Arduino, Breadboard and Multimeter Work in teams of two! living with the lab 1 © 2012 David Hall.
Cascaded switching of a solenoid valve living with the lab transistor relay solenoid valve © 2012 David Hall.
Switches & whiskers on the Arduino living with the lab lever arm switches mounted to Arduino © 2012 David Hall.
220  470  Gnd5V Currents Through Parallel Resistors 1 living with the lab © 2012 David Hall.
Using Hobby Servos with the Arduino living with the lab © 2012 David Hall.
Introduction to Microsoft Excel living with the lab © 2012 David Hall.
Voltage Drops Around Closed Loops 470  220  5V   220  living with the lab © 2012 David Hall.
Kirchoff’s Current Law (KCL) living with the lab University of Pennsylvania Library and Wikipedia Gustav Kirchoff (left) and Robert Bunsen (right) Bunsen.
Adding a Barrel Jack to a Battery Pack living with the lab © 2012 David Hall.
Using for loops to control LEDs living with the lab 1 1 arduino.cc the for statement allows us to repeat a block of commands a limited number of times.
Building Circuits.
Pump Fabrication Day Group A will draw their pump
Controlling Servos with the Arduino
Connecting Switches.
Series and Parallel Resistors
Pump Project Requirements
Introduction to the Arduino
Why Won’t My Arduino Work?
Troubleshooting Your Multimeter
Using servos.
Servo Library and Functions
Line Following Tips photoresistor circuits
Pump Project Overview.
Robot Assembly.
How to Use Dial Calipers
Controlling a Motor with Cascading Switches
Introduction to Transistors
Introduction to the Fishtank
Conservation of Mass Problem
Maxbotix Ultrasonic Distance Sensor
Conductivity Sensor.
Introduction to Transistors
Servo Library and Functions
Troubleshooting Your Multimeter
a few of my favorite sensors
Relays.
using for loops to control LEDs
using the Arduino to make LEDs flash
Acquiring Data from an ADXL335 Accelerometer
Using Photoresistors with an Arduino
Line Following Tips photoresistor circuit
Torque and RPM of Gears
Conservation of Mass Problem
Data Types.
analog and digital measurements
Using “if” statements.
Controlling the Heater
Design Project Forecast
Digital Input from Switches
Implementing Switches Using Interrupts
Arduino: For Loops.
Non-Concurrent Force Systems
IR Object Detection IR detector IR LED IR light reflected off object
Radio Frequency Transmitter and Receiver
Interfacing a Rotary Encoder with an Arduino
Brainstorming.
Conservation of Mass Problem
Non-Concurrent Force Systems
Evaluating Design Alternatives
Counting Servo Gear Teeth (FS90R Servos)
Static Equilibrium Problem
Reservoir Loop.
Freshman Design Expo Presentations
Gearmotor Efficiency W table top gearmotor pulley string.
Presentation transcript:

RGB LEDs

DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms

Hooking Up the LED Ground red on the end closest to the longest leg GND green blue red Ground longest leg wired to ground red on the end closest to the longest leg wired to digital pin 9 green next to the longest leg, but not on the end wired to digital pin 10 blue on the end, but not next to the longest wired to digital pin 11 220Ω pin9 220Ω pin10 220Ω pin11

Use these sketches to make your LED blink make it blink red make it blink green make it blink blue int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(redLED, 255); delay(1000); analogWrite(redLED, 0); int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(greenLED, 255); delay(1000); analogWrite(greenLED, 0); int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(blueLED, 255); delay(1000); analogWrite(blueLED, 0); change to greenLED change to blueLED

Enter this program to make your red LED to fade in The analogWrite() Function Enter this program to make your red LED to fade in The analogWrite() function allows a digital pin to simulate a voltage varying from 0V to 5V by turning a digital pin on and off at about 500Hz. int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { for (int i=0; i<256; i++) { analogWrite(redLED, i); delay(5); 0V 5V analogWrite(redLED,0) 0% duty cycle; simulates a voltage of 0 0V 5V analogWrite(redLED,64) 25% duty cycle; simulates a voltage of 1.25V 0V 5V analogWrite(redLED,127) 50% duty cycle; simulates a voltage of 2.5V 0V 5V analogWrite(redLED,191) 75% duty cycle; simulates a voltage of 3.75V 0V 5V analogWrite(redLED,255) 100% duty cycle; simulates a voltage of 5V

Light up Two Colors to Make Magenta, Cyan & Yellow make it blink magenta (purple) make it blink cyan make it blink yellow int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(redLED,255); analogWrite(blueLED,255); delay(200); analogWrite(redLED,0); analogWrite(blueLED,0); int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(greenLED,255); analogWrite(blueLED,255); delay(1000); analogWrite(greenLED,0); analogWrite(blueLED,0); int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { analogWrite(redLED,255); analogWrite(greenLED,255); delay(1000); analogWrite(redLED,0); analogWrite(greenLED,0);

Use “for loops” to create fades between colors red to green and back Create Some Crazy Fades int redLED = 9; int greenLED = 10; int blueLED = 11; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); } void loop() { for (int i=0; i<256; i++) { analogWrite(redLED,255-i); analogWrite(greenLED,i); delay(10); analogWrite(redLED,i); analogWrite(greenLED,255-i); Use “for loops” to create fades between colors red to green and back to red (see code here) red to blue and back blue to green and back across the visible spectrum and back do some tricks of your own! Photo by xenia at Morguefile.com Did you know that each pixel on your computer or phone display has a red, green and blue subpixel whose intensities can be controlled to produce millions of color variations?