arduino controlling the wild rgb led strips
play

Arduino: Controlling the Wild RGB LED Strips! Slides and Programs: - PowerPoint PPT Presentation

Arduino: Controlling the Wild RGB LED Strips! Slides and Programs: http://pamplin.com/dms/ Brady Pamplin DMS: @bpamplin DMS SSID: DMS Member Password: dms--109238 Agenda Physical Computing Microcontrollers,


  1. Arduino: Controlling the Wild RGB LED Strips! Slides and Programs: http://pamplin.com/dms/ Brady Pamplin DMS: @bpamplin DMS SSID: “DMS Member” Password: dms--109238

  2. Agenda • Physical Computing • Microcontrollers, Arduino, Wemos • Is Raspberry Pi a microcontroller? • Parts Kit and the Breadboard • Arduino IDE – Portable and Standard • Map of files for this class • CH340 Driver • IDE Installation and Verification – Lab time • WS1812B RGB LED Strips Definition • Options and Safety • Strips Programs • Lab time Arduino: Controlling the Wild LED Strips! 2

  3. Physical Computing Physical computing [systems] are interactive systems that can sense and respond to the world around them. https://en.wikipedia.org/wiki/Physical_computing Common inexpensive hobby sensors and components include: Water Lever Sensor LEDs IR Receiver Module LCD Display IR Emission Module RGB LED Strips Tilt Switch Module Ultrasonic Distance Sensor Button Module Temperature Sensor Buzzer Module Light Sensor Photo-resistor Module Relay Photo-interrupter Module Flame Sensor Module Tap Module Metal Touch Module Membrane Switch Module Sound Module Shake Module Laser Emit Module Arduino: Controlling the Wild LED Strips! 3

  4. Terminology Microprocessor – CPU for servers, PCs, laptops • Requires external memory and IO controllers • All pins dedicated for specific purposes • A primary goal is speed Microcontroller, MCU - embedded computer - pins available for sensors and actuators • Chip includes limited size CPU, flash memory, IO capabilities • Great for Physical Computing • 50 in typical car - 100 or more in top end luxury cars • ATmega328 used in Arduino Uno, Nano • ESP8266 used in Wemos System on Chip, SoC • Integrates all components of a computer or other electronic system • Digital, analog, mixed-signal, radio frequency • Raspberry Pi, cell phones Arduino: Controlling the Wild LED Strips! 4

  5. Terminology (Cont’d) Microcontroller boards - microcontroller and support components • Arduino Uno, Nano,… - ATmega328 • Wemos D1 Mini - ESP8266 Arduino IDE – Integrated Development environment • GUI based software to manage all steps from program development to downloading software into microcontrollers • Started with Arduino boards and others were added Arduino: Controlling the Wild LED Strips! 5

  6. How much “On top of all the hardware components, today’s cars are running an enormous code is in amount of software. Mainstream cars my car? may have up to 10 million lines of code and high-end luxury sedans can have nearly 100 million —that’s about 14 times more than even a Boeing 787 Dreamliner jet .” https://www.usatoday.com/story/tech/c olumnist/2016/06/28/your-average-car- lot-more-code-driven-than-you- think/86437052/ Arduino: Controlling the Wild LED Strips! 6

  7. Microcontrollers and Raspberry Pi Comparison Arduino Lolin/Wemos RPi 3B+ Nano/UNO D1 Mini Category Microcontroller Microcontroller Computer system aaa Chip ATmega328 ESP8266 Broadcom BCM2837B0 Flash 32K – 2K 4M Add in >= 8G bootloader SRAM 2K 80K 1 GB WiFi No Yes Yes Voltage 5 3.3 3.3 Digital I/O Pins 14 11 24 Analog Input Pins 6 1 0 Active programs 1 1 Dozens Clock speed 16 MHz 80 MHz 1.4 GHz USB Cable Nano – Mini Micro Micro Uno - B Arduino: Controlling the Wild LED Strips! 7

  8. Arduino Nano Close-up

  9. If the 5V, 3V3 or output data pins are shorted directly to ground, there is a danger of damaging the microcontroller or USB port. These circuits use five volts and less so there is no danger to a person. USB ports provide a limited amount of power. LED strips demand a lot of power. Be careful if you increase power. Arduino: Controlling the Wild LED Strips! 9

  10. • Arduino Nano • Breadboard Parts Kit • WS2812B RBG LED Strip • 10k Linear Potentiometer • LEDs and 330 Ω Resistors • USB mini cable • Jumper wires Arduino: Controlling the Wild LED Strips! 10

  11. Breadboards and Jumpers Arduino: Controlling the Wild LED Strips! 11

  12. English language site • https://sparks.gogo.co.nz/ch340.html Install Chip manufacturer site – Chinese CH340 • http://www.wch.cn/download/CH341SER_EXE.html Driver • Windows zip for http://www.wch.cn/downloads/file/5.html • Linux zip Arduino http://www.wch.cn/downloads/file/177.html Clones • Mac zip http://www.wch.cn/downloads/file/178.html Arduino Install Information 12

  13. Characteristics of Standard Arduino IDE • Programs in protected area – • Users / (ID) / Program Files / Arduino • Sketches and libraries in user area – • Users / (ID) / My Documents/Arduino • Supported for Windows, Apple, Linux Arduino Install Information 13

  14. Why Use Portable Arduino IDE? • All files in single user area – often the Desktop • Easy to deploy in class and use at home • Easy to run from USB memory stick • All programs will be installed in (root)\portable\sketchbook • Libraries will install in (root)\portable\sketchbook\libraries • Avoids conflict with existing installation • Supported for Windows and Linux only https://www.arduino.cc/en/Guide/PortableIDE Arduino Install Information 14

  15. USB Flash Files for Class Windows users need only copy first directory structure to the Desktop. Apple and Linux users need the last to do a normal installation plus the last two files. arduino-1.8.10_a Full Portable Arduino IDE with programs, libraries and slides for Windows only. • (root)\arduino.exe • (root)\portable\sketchbook - programs • (root)\portable\sketchbook_slides - slides • (root)\portable\sketchbook\libraries – user libraries progs_nov19.zip Program files slides__nov19.zip Class slides Arduino: Controlling the Wild LED Strips! 15

  16. Install Portable Arduino IDE Windows Only Copy arduino-1.8.10_a from USB drive to Desktop This contains the IDE files, sketchbook programs for this class and a set of libraries used in DMS classes Remove USB Drive Open the new folder and double click arduino.exe or arduino application Arduino: Controlling the Wild LED Strips! 16

  17. Install Standard Arduino IDE Install Arduino IDE: https://www.arduino.cc/en/Main/Software Unzip and copy program files into Arduino folder Install FastLED library: • Tools / Library Manager… • Search for FastLED by Daniel Garcia • Install For Apple see also: https://www.youtube.com/watch?v=4tOAwJ8Rn9c Arduino: Controlling the Wild LED Strips! 17

  18. Arduino IDE Control Panel Arduino Install Information 18

  19. Configure Tools Tab Tools / Board: Arduino Nano Tools / Processor: ATmega 328 or ATmega 328P (Old Bootloader) Arduino Install Information Tools / Port: Port with Arduino 19

  20. Select Program From Sketchbook Arduino Install Information 20

  21. Verify with Blink Example File / Examples / 01.Basics / Blink Select the Upload Button Watch for LED to blink slowly Change delay times Upload again Arduino: Controlling the Wild LED Strips! 21

  22. Blink - Everyone’s first program void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } Program: File / Examples / 01.Digital / Blink 22

  23. Blink an LED Add an LED, resistor and two wires to light LED when D13 is high. Anode to the left. Run Blink. Arduino: Controlling the Wild LED Strips! 23

  24. Light Two LEDs Alternately Add an LED, resistor and two wires to light LED when D13 is high. Anode to the left. Run Blink. Add a second LED, resistor and two wires to light second LED when D13 is low. Anode to the right. Run Blink. Arduino: Controlling the Wild LED Strips! 24

  25. Short Lab Time for Installation and Verification NTP clock to be used in Arduino: Using I2C LCD Displays class. Arduino: Controlling the Wild LED Strips! 25

  26. Can You Fade an LED? File/ Examples / 02.Analog / Fading Using the previous circuit, move the jumper from D13 to D9. This uses Pulse Width Modulation (PWM) to make the LED appear to dim. Only pins 3, 5, 6, 9, 10 and 11 will do PWM. Program: File / Examples / 03.Analog / Fading https://www.arduino.cc/en/Tutorial/PWM Arduino: Controlling the Wild LED Strips! 26

  27. WS2812B RGB LED Strips This class uses WS2812B aka Adafruit Neopixels Options: • LEDs/meter: 30, 60, 144 • Background: black, white • Length: 1 meter (39 inches), 5 meters (16 feet) • Waterproof: Silicon coating, Silicon tube, none • Voltage: 5 volts Arduino: Controlling the Wild LED Strips! 27

  28. WS2812B 5050 RGB LED Strips Arduino: Controlling the Wild LED Strips! 28

  29. Walk on the Safe Side They say that LEDs use very little power. While that is true, these are very bright and the USB can supply a limited amount of current. One of these on maximum white brightness (255) needs 60mA (0.06 amp). Ten require 600mA (0.6 amp) which exceeds available power on many USB ports. Example programs are set to a brightness level of 10. It is safe to increase this to 50. 36 white LEDs at brightness 50 require less than 500mA which is safe. You are on your own to increase power beyond 50. My parts are not at risk. Your USB ports may be. USB ports have a “self resettable” fuse but I do not care to test it. Arduino: Controlling the Wild LED Strips! 29

Recommend


More recommend