Skip to content

Instantly share code, notes, and snippets.

@gigafide
gigafide / servo_control.py
Last active January 30, 2023 21:17
Raspberry Pi Pico servo and potentiometer control
from machine import Pin, PWM, ADC
from time import sleep
pot = ADC(Pin(28))
servo = PWM(Pin(0))
servo.freq(50)
def move_servo(degrees):
if degrees > 180:
@gigafide
gigafide / pico_servo_sweep.py
Last active January 30, 2023 21:01
Simple Raspberry Pi Pico Servo Sweep
from machine import Pin, PWM
import time
servo = PWM(Pin(0))
servo.freq(50)
while True:
for position in range(1000, 9000, 50):
servo.duty_u16(position)
time.sleep(0.1)
@gigafide
gigafide / web_scraping_selenium.py
Last active December 13, 2022 17:01
Web Scraping On A Raspberry Pi Using Selenium
#INSTALL SELENIUM BEFORE RUNNING THIS CODE
#pip3 install selenium
import csv
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
import getpass
from selenium.common.exceptions import NoSuchElementException
@gigafide
gigafide / basic_web_scraping.py
Created December 13, 2022 16:44
Basic Web Scraping Using Python and BeautifulSoup
#IMPORT LIBRARIES
from bs4 import BeautifulSoup
import requests
#REQUEST WEBPAGE AND STORE IT AS A VARIABLE
page_to_scrape = requests.get("http://quotes.toscrape.com")
#USE BEAUTIFULSOUP TO PARSE THE HTML AND STORE IT AS A VARIABLE
soup = BeautifulSoup(page_to_scrape.text, 'html.parser')
@gigafide
gigafide / stepper_test.ino
Created March 9, 2019 03:20
Arduino test code for the Sparkfun EasyDriver stepper motor controller
#define stp 2
#define dir 3
char user_input;
int x;
int y;
int state;
void setup() {
pinMode(stp, OUTPUT);
@gigafide
gigafide / motion_music.py
Created November 10, 2018 03:53
Play music with a PIR motion detector and a Raspberry PI
#!/usr/bin/env python
import RPi.GPIO as GPIO
import pygame
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)
pygame.mixer.init()
@gigafide
gigafide / mind_control_remote.ino
Last active February 15, 2020 02:25
Arduino code for using a Star Wars Force Trainer headset as an TV remote control.
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Brain.h>
IRsend irsend;
Brain brain(Serial);
const int ledPin = 3;
long interval = 500;
long previousMillis = 0;
int ledState = LOW;
int medValue;
@gigafide
gigafide / Arduino_IRreader.ino
Created October 29, 2018 14:51
Reads IR code signals from a remote control
#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
#Import the required dependencies
import picamera
from PIL import Image
from time import sleep
#Start a loop with the Pi camera
with picamera.PiCamera() as camera:
#Set the resolution, fps, and then start the preview
camera.resolution = (640, 480)
camera.framerate = 24
@gigafide
gigafide / alexa_ruxpin.ino
Created December 20, 2016 21:38
Code to convert audio into servo movements for a Teddy Ruxpin doll.
#include <Servo.h>
//declare constants for audio input
int Musicread = 0;
int Music;
//LED pin is only for testing
const int ledPin = 13;
//declare constants for servos