Skip to content

Instantly share code, notes, and snippets.

@mitchtech
mitchtech / SerialServoControl.ino
Created July 1, 2012 19:26
Arduino Serial Servo Control
/*******************************************************
* SerialServoControl Sketch
* Written by Ryan Owens for SparkFun Electronics
* 7/15/11
*
* This sketch listens to serial commands and uses the data
* to set the position of two servos.
*
* Serial Command Structure: 2 bytes - [ID Byte][Servo Position byte]
* ID byte should be 0 or 1.
/* Arduino USB Keyboard HID demo
* Volume+/Volume-/Mute keys
*/
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */
#define PIN_VOLUME_UP 5
#define PIN_VOLUME_DOWN 6
#define PIN_MUTE 7
/* Arduino USB Keyboard HID demo
* Cut/Copy/Paste Keys
*/
#define KEY_LEFT_CTRL 0x01
#define KEY_LEFT_SHIFT 0x02
#define KEY_RIGHT_CTRL 0x10
#define KEY_RIGHT_SHIFT 0x20
uint8_t buf[8] = {
/* Arduino USB HID Keyboard Demo
* Random Key/Random Delay
*/
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */
void setup()
{
Serial.begin(9600);
#!/usr/bin/env python
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
import os
USERNAME = "username@gmail.com"
#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
USERNAME = "username@gmail.com"
PASSWORD = "password"
MAILTO = "mailto@gmail.com"
msg = MIMEText('This is the body of the email')
msg['Subject'] = 'The email subject'
#!/usr/bin/env python
import time
import os
STEP = 100
DELAY = 0.5
def pwm(pin, angle):
print "servo[" + str(pin) + "][" + str(angle) + "]"
#!/usr/bin/env python
import feedparser
USERNAME = "username@gmail.com"
PASSWORD = "password"
response = feedparser.parse("https://" + USERNAME + ":" + PASSWORD + "@mail.google.com/gmail/feed/atom")
unread_count = int(response["feed"]["fullcount"])
for i in range(0,unread_count):
@mitchtech
mitchtech / cpu_serial_servo.py
Created July 1, 2012 17:51
Arduino Physical CPU/Memory Gauges
#!/usr/bin/env python
import serial, sys, time, psutil
# Assign Arduino's serial port address
# Windows example
# usbport = 'COM3'
# Linux example
# usbport = '/dev/ttyUSB0'
# MacOSX example
# usbport = '/dev/tty.usbserial-FTALLOK2'
import RPi.GPIO as GPIO, feedparser
USERNAME="username@gmail.com"
PASSWORD="password"
GPIO_PIN=12
GPIO.setmode(GPIO.BOARD)
GPIO.setup(GPIO_PIN, GPIO.OUT)
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD + "@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
if newmails > 0:
GPIO.output(GPIO_PIN, True)
else: