1-Get-Started-with-PicoBricks3

#1 Get Started with PicoBricks – PicoBlink

In real life, the employee, who has just started to learn the job, first undertakes the most basic task.The cleaner first learns to use the broom, the cook learns to use the kitchen utensils, the waiter to carry a tray. We can increase these examples. The first code written by newcomers to software development is known as β€œHello World”. Printing β€œHello World” as soon as the program starts on the screen or console window in the language they use is the first step in programming. Like a baby starting to crawl… The first step to robotic c oding, also known as physical programming, is the Blink application. It means winking at robotic coding.

Details and Algorithm

There are 1 x 5mm red LED and 1 x WS2812B RGB LED on Picobricks. While normal LEDs can light up in one color, RGB colors can light up in different colors, both primary and secondary colors. In this project we will use the red LED on Picobricks.

In the project, we will write the necessary codes to turn on the red LED on Picobricks, turn it off after a certain time, turn it on again after a certain time, and repeat these processes continuously.

Components

1X PicoBricks

Wiring Diagram

MicroBlocks Codes of the PicoBricks

You can access the Microblocks codes of the project by dragging the image to the Microblocks Run tab or click the button

MicroPython Codes of the PicoBricks

from machine import Pin#to acces the hardware picobricks
led = Pin(7,Pin.OUT)#initialize digital pin as an output for led
push_button = Pin(10,Pin.IN,Pin.PULL_DOWN)#initialize digital pin 10 as an input
while True:#while loop
    logic_state = push_button.value();#button on&off status
    if logic_state == True:#check the button and if it is on
        led.value(1)#turn on the led
    else:
        led.value(0)#turn off the led

Arduino C Codes of the PicoBricks

void setup() {
  // put your setup code here, to run once:
  pinMode(7,OUTPUT);//initialize digital pin 7 as an output
  pinMode(10,INPUT);//initialize digital pin 10 as an input

}
void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(10)==1){//check the button and if it is on
    digitalWrite(7,HIGH);//turn the LED on by making the voltage HIGH
  }
  else{
    digitalWrite(7,LOW);//turn the LED off by making the voltage LOW
  }
  delay(10);//wait for half second
}

Project Image

Project Video

Project Proposal πŸ’‘

Can we light the LED with different time intervals? For example; flashing of the LED several times per second, several times every half second.

Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *