Arduino | Pixel ON
Overview
How to set the colour and brightness of the pixel and turn it on.The Code
LAUNCH BLOCK CODE#include <Adafruit_NeoPixel.h> Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1,7,NEO_GRB + NEO_KHZ800); void setup() { pixels.begin(); pixels.setBrightness(50); } void loop() { pixels.setPixelColor(0,pixels.Color(153,51,153)); pixels.show(); }
Code Breakdown
Set-up
- Connect the board to your computer using the USB-C cable.
- If you don’t have the Adafruit Neopixel Library you will need to install it
- Learn more about how to Install a library
- Upload the code (for Arduino IDE uploading see Upload a Sketch in Arduino IDE)
Code Logic
- Setup()
- Initialize the pixel library. Set the number of pixels (1) and the brightness (50)
- Loop()
- Set the colour of the pixel
- Show the colour on the pixel
Blocks Used
- Adafruit -> NeoPixel -> Init
- LED Num = 1
- Pin# = 7
- Brightness = 50
- Adafruit -> NeoPixel -> Color
- Set to any colour using the colour picker
- Adafruit -> NeoPixel -> Show
*Note – if the Adafruit blocks are unavailable in the sidebar, you can enable them under the options (gear menu)