Entry Week 3

In week one I expressed my interest in the wireless capabilities that the Arduino provides. from my understanding, coupled with other devices or microcontrollers, the ardurino can control projects from quite a distance. After researching a few projects there was one that caught my attention. The project was an wireless 2 axes accelerometer. The project seemed to be easy enough to attempt to duplicate.

 

If I’m able to duplicate this project it will be the beginnings of creating a custom controller to work with other projects.

 

 

Along with the schematic the creator also provided the code.

import serial  # pySerial
import struct
import sys

THRESHOLD = 5

tty = sys.argv[1]

s = serial.Serial(tty, 9600)
movement = None
while True:
if s.read() == chr(0x7e):  # Packet start indicator.
length, api_id = struct.unpack(‘>Hc’, s.read(3))
if api_id == chr(0x92):  # IO packet type.
# Lots of bytes we don’t care about followed by 3 shorts.
z, y, x = struct.unpack(‘>xxxxxxxxxxxxxxxHHH’,
s.read(length – 1))
print z, y, x
if (movement is not None and
abs(z + y + x – movement) > THRESHOLD):
print ‘You moved!’
movement = z + y + x

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply