
There’s a Robosumo competition coming up. The microcontroller chosen for the job was the PIC 18F14k50. The sensors being used are Sharp infrared rangefinder (to locate the opposing robot), and IR colour detecting sensors (to detect when the robot has reached the edge of the ring). All of these sensors give out a voltage somewhere between 0-5v. In order to start writing some code, it is extremely helpful to read the output of each analog channel in real time.
This is the code used to read from the analog channel and transmit it over serial:
On the computer end of things, a python script is used to print the incoming serial data to the screen.
import serial import time import numpy as np import cv2 ser = serial.Serial('/dev/ttyUSB0', 9600) ser.close() ser.open() while True: print ser.readline()
Link to the Python script : https://drive.google.com/file/d/0B5yKKaW8az34NE9hdHdONWFWaE0/edit?usp=sharing
Link to the C file : https://drive.google.com/file/d/0B5yKKaW8az34TlNTX1QzZEVkWmM/edit?usp=sharing