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
/* Otto DIY Robot | |
by Suad Anwar | |
This sample code is for Otto DIY Robot using Maker Pi RP2040 board. | |
https://my.cytron.io/p-maker-pi-rp2040-simplifying-robotics-with-raspberry-pi-rp2040 | |
*/ | |
#include <Servo.h> | |
#define PIN_YL 12 //servo[0] left leg |
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, PWM | |
import utime | |
Trig = Pin(27, Pin.OUT) | |
Echo = Pin(26, Pin.IN, Pin.PULL_DOWN) | |
Buzzer = PWM(Pin(18)) | |
def CheckDistance(): | |
SpeedOfSoundInCM = 0.034 |
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
const int LED = 10; | |
long random_led; | |
long random_time; | |
int difer_time(); | |
void setup() { | |
pinMode(LED, OUTPUT); | |
} | |
int min_led = 200; |
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 time | |
import board | |
import pwmio | |
from adafruit_motor import servo | |
# create a PWMOut object on Pin GP27. | |
pwm = pwmio.PWMOut(board.GP27, duty_cycle=2 ** 15, frequency=50) | |
# Create a servo object, my_servo. | |
my_servo = servo.Servo(pwm) |
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 io | |
import picamera | |
import cv2 | |
import numpy | |
#Create a memory stream so photos doesn't need to be saved in a file | |
stream = io.BytesIO() | |
#Get the picture (low resolution, so it should be quite fast) | |
#Here you can also specify other parameters (e.g.:rotate the image) |
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 machine | |
import utime | |
sensor_temp = machine.ADC(machine.ADC.CORE_TEMP) | |
conversion_factor = 3.3 / (65535) | |
file = open("temps.txt", "w") | |
while True: | |
reading = sensor_temp.read_u16() * conversion_factor | |
temperature = 27 - (reading - 0.706)/0.001721 |
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 SENSOR 3 | |
#define PIEZO 8 | |
#define NOTE_G5 784 | |
#define NOTE_C6 1047 | |
int Sound[] = {NOTE_G5, NOTE_C6}; | |
int SoundNoteDurations[] = {12, 8}; | |
#define playSound() playMelody(Sound, SoundNoteDurations, 2) |
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
#include "Seeed_BMP280.h" | |
#include <Wire.h> | |
#include <Arduino.h> | |
#include <U8x8lib.h> | |
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); | |
BMP280 bmp280; | |
void setup() { | |
Serial.begin(9600); |
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
#include "DHT.h" | |
#include <Arduino.h> | |
#include <U8x8lib.h> | |
#define DHTPIN 3 | |
#define DHTTYPE DHT11 // DHT 11 | |
DHT dht(DHTPIN, DHTTYPE); | |
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); | |
#define LED 4 | |
#define PIEZO 5 |
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 gpiozero import MotionSensor | |
from picamera import PiCamera | |
import time | |
from time import sleep | |
pir = MotionSensor(4) | |
camera = PiCamera() | |
camera.rotation = 180 | |
while True: |