Fizikal Komputer Topik Satu 1- Salam dan LED Blinking Arduino Vs Raspberry Pi Pico vs BBC Microbit

Menulis bahasa pengaturcaraan pertama dengan menggunakan istilah "Salam"

Arduino IDE

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
Serial.println("Salam");
delay(500);
}
view raw salam.ino hosted with ❤ by GitHub

Microsoft Makecode


Micropython (Thonny)

#ini untuk looping selamanya
while True:
print("Salam")
#untuk sekali saja, code di bawah ini
#print("Salam")
view raw salamPython.py hosted with ❤ by GitHub

 

 

 

Menulis Coding LED dengan TIGA 3 jenis sistem pengawal Mikro

Komponen yang diperlukan:

1- Jumper atau wayar

2- LED

3- Perintang 200 -500 Ohm

 Arduino

 

 

 

 

 

Coding arduino IDE 

view raw LEDblink.ino hosted with ❤ by GitHub

 

BBC Microbit  

 

 

 

 

 

Coding Makecode

 

 

 Raspberry Pico



 

 

 

 

 

 

Coding Micropython 

from machine import Pin
import time
lampu = Pin(15, Pin.OUT)
while True:
lampu.value(1)
print("ON")
time.sleep(1)
lampu.value(0)
print("OFF")
time.sleep(1)
 

 

SEGMEN BONUS

Arduino Code

 sini sini sini

Processing Code

import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(1900, 1000);
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, "COM11", 9600);
}
void draw()
{
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
if (val == 0) { // If the serial value is 0,
fill(0); // set fill to black
rect(300, 700, 350, 140);
fill(155,150,150);
textSize(128);
text("OFF",350,810);
}
else { // If the serial value is not 0,
fill(200,150,80); // set fill to light gray
rect(300, 700, 350, 140);
fill(255,0,50);
textSize(128);
text("ON",350,810);
}
}
view raw gistfile1.pde hosted with ❤ by GitHub


END

Comments