Ece department packedcolor indexed integer in internal

This preview shows page 12 - 15 out of 16 pages.

ECE Department strip.setPixelColor(PixelID, PackedColor) indexed integer) in internal memory <uint32_t> = strip.Color(<uint8>,<uint8>,<uint8>) Example: PackedColor = strip.Color(Red,Blue,Green) Returns a 32-bit ‘packed’ integer representing the RGB values (ie., Red*256^2 + Blue*256 + Green) void = strip.show() Example: strip.show() Send stored configuration to LED strip in single burst transmission We will define a couple colors, then store the desired data into the strip object. Once everything is set, we’ll call the show() method to dump the data over the digital data link to the string of pixels. void loop() { //Setup some colors int PixelColorBlue = strip.Color( 0, 0, 128); int PixelColorRed = strip.Color( 80, 0, 4); int PixelColorGold = strip.Color( 60, 50, 5); //Set first pixel to blue strip.setPixelColor(0, PixelColorBlue); //set second pixel to red strip.setPixelColor(1, PixelColorRed); //set third pixel to Gopher Gold! strip.setPixelColor(2, PixelColorGold); strip.show(); delay(1000); //wait 1sec //set second and third pixel to Gopher Gold! and Red strip.setPixelColor(2, PixelColorRed); strip.setPixelColor(1, PixelColorGold); strip.show(); delay(1000); //wait 1sec} } Verify and flash your code to your Photon, check that the LEDs function as intended. It is important to note that, NeoPixels hold their color settings until the next show() method call or 5V power goes away. So, there is no need to continually update them. Sensors - Human Input Devices Accepting input from a human being is a useful feature for microcontrollers. While this can appear to be a simple task, there are 1 You can actually see the definition of this method in the file “neopixel.c” on line 699. This is a useful place to look if you need to figure out how an undocumented library functions. Page 12
3V3 A2 Photon External Circuit EE 2361 Lab # 4 ECE Department several pitfalls. We’re going to start by looking into setting up a single push button and potentiometer (knob) as input devices. The push button is a normally open momentary switch, this means that if we tie one terminal of the push button to 3V3 and the other terminal to an input of the Photon set to “INPUT_PULLDOWN” it results in the following circuit. When the button is “not pushed”, it results in the Photon’s internal “pulldown” resistor pulling the input to ground, 0.0V, or a “low” state. Think of this as a default state. When the button is pushed the input gets connected to 3V3 with a low resistance. The resistors have a tug of war and the lower resistance path wins, pulling the input to 3.3V or a “high” state. The potentiometer is a three terminal device. It is implemented physically as a very long resistor with a contact on each end (terminals 1 and 3) and a “swiper” that can contact anywhere in-between (terminal 2). When the two fixed terminals are connected to the supplies (GND and 3V3), the “swiper” terminal will output a voltage between 0.0V and 3.3V depending on the position of the swiper. This can easily be wired into an analog input terminal. Now wire up a push-button and a potentiometer as described above and shown in the following circuit: Page 13
EE 2361 Lab # 4 ECE Department

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture