Menulis bahasa pengaturcaraan pertama dengan menggunakan istilah "Salam"
Arduino IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
// initialize serial communication at 9600 bits per second: | |
Serial.begin(9600); | |
} | |
void loop() { | |
Serial.println("Salam"); | |
delay(500); | |
} |
Microsoft Makecode
Micropython (Thonny)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ini untuk looping selamanya | |
while True: | |
print("Salam") | |
#untuk sekali saja, code di bawah ini | |
#print("Salam") |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int LEDkuning = 7; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(LEDkuning,OUTPUT); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
digitalWrite(LEDkuning,HIGH); | |
delay(1000); | |
digitalWrite(LEDkuning,LOW); | |
delay(1000); | |
} |
BBC Microbit
Coding Makecode
Raspberry Pico
Coding Micropython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
END
Comments
Post a Comment