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 java.util.ArrayList; | |
class Packet { | |
static final int PACKET_STX = 0xAB; | |
static final int PACKET_ETX = 0x7D; | |
static final int PACKET_CMD_GET_PM2008 = 0; | |
static final int PACKET_POS_STX = 0; | |
static final int PACKET_POS_LEN = 1; |
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 java.util.ArrayList; | |
class Packet { | |
static final int PACKET_STX = 0xAB; | |
static final int PACKET_ETX = 0x7D; | |
static final int PACKET_CMD_GET_PM2008 = 0; | |
static final int PACKET_POS_STX = 0; | |
static final int PACKET_POS_LEN = 1; |
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 java.util.ArrayList; | |
class Packet { | |
static final int PACKET_STX = 0xAB; | |
static final int PACKET_ETX = 0x7D; | |
static final int PACKET_CMD_GET_PM2008 = 0; | |
static final int PACKET_POS_STX = 0; | |
static final int PACKET_POS_LEN = 1; |
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() { | |
Serial.begin(9600); | |
while(!Serial){} | |
} | |
void loop() { | |
Serial.print("a"); | |
delay(1000); | |
Serial.print("b"); |
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
#define PIN_LED 13 | |
void setup() { | |
pinMode(PIN_LED, OUTPUT); | |
digitalWrite(PIN_LED, LOW); | |
Serial.begin(9600); | |
while (!Serial) {} | |
} |
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 board | |
from digitalio import DigitalInOut, Direction | |
from time import sleep | |
led = DigitalInOut(board.BLUE_LED) | |
led.direction = Direction.OUTPUT | |
while True: | |
led.value = True | |
print('ON!!') |
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 board | |
from digitalio import DigitalInOut, Direction, Pull | |
led = DigitalInOut(board.BLUE_LED) | |
led.direction = Direction.OUTPUT | |
switch = DigitalInOut(board.SWITCH) | |
switch.direction = Direction.INPUT | |
switch.pull = Pull.UP |
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 board | |
from analogio import AnalogIn | |
from time import sleep | |
adc = AnalogIn(board.A5) | |
while True: | |
print(adc.value) # 16 bit 2 ^ 16 = 65536 | |
sleep(0.1) |
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 board | |
from pwmio import PWMOut | |
from time import sleep | |
led = PWMOut(board.BLUE_LED, frequency=5000, duty_cycle=0) # 2 ^ 16 = 65536 | |
while True: | |
for i in range(100): # 0 ~ 99 | |
if i < 50: | |
led.duty_cycle = int(65535 * ((i * 2) / 100)) # 0 >>> 65535 |
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 board | |
from busio import I2C | |
import adafruit_ssd1306 | |
i2c = I2C(board.SCK, board.MOSI) | |
display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3c) | |
# clear | |
display.fill(0) |