It is called the state of being autonomous when electronic systems make a decision based on the data they collect and perform the given task automatically. The components that enable electronic systems to collect data from their environment are called sensors. Many data such as the level of light in the environment, how many degrees the air temperature is, how many lt/min water flow rate, how loud the sound is, are collected by the sensors and transmitted to PicoBricks as electrical signals, that is data. There are many sensors in Picobricks. Knowing how to get data from sensors and how to interpret and use that data will improve project ideas like reading a book improves vocabulary.
In this project, with PicoBricks, we will enable the LED to turn on when the amount of light decreases in order to understand the working systems of the systems where the lighting is turned on automatically when it gets dark.
Components
1X PicoBricks
Wiring Diagram
You can code and run Picobricks’ modules without wiring. If you are going to use the modules by separating them from the board, you should make the module connections with grove cables.
import time
from machine import Pin, ADC
from picobricks import WS2812
#define the library
ldr = ADC(Pin(27))
ws = WS2812(6, brightness=0.4)
#define the input and output pins
#define colors
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
COLORS = (RED, GREEN, BLUE)
#RGB color Code
while True:#while loop
print(ldr.read_u16()) #print the value of the LDR sensor to the screen.
if(ldr.read_u16()>10000):#let's check the ldr sensor
for color in COLORS:
#turn on the LDR
ws.pixels_fill(color)
ws.pixels_show()
else:
ws.pixels_fill((0,0,0)) #turn off the RGB
ws.pixels_show()
Arduino C Codes of the PicoBricks
GitHub Project Page