Blink Application
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
}
Tags: