Help bring more traffic! Stumble This!

HTML hit counter - Quick-counter.net

Wednesday, January 19, 2011

Spoke Too Soon

Well all is not as it seems.
Though the Arduino software installed easier than I thought, it turns out a few more extra steps are needed to get to work.

At first I couldn't select any of the serial ports. After giving up for a while, I came across this webpage on the arch wiki. I'm pretty sure I looked before and couldn't find it, oh well.
Turns out it was a permission issue, but giving the user the correct permissions didn't seem to help either.

So what I did was create a launcher that runs the command sudo arduino from the terminal. I have it set to keep the terminal open while the program runs so I can see what TX and RX versions are uploaded. It sometimes comes in handy.

Now there's just one issue I can't seem to get across.
When I upload the program to the board, it blinks as usual, but it doesn't loop for some weird reason.

Well even though I couldn't correctly upload the program, I did finish the program needed for the solar tracker. It's surprisingly easier than I had anticipated.

And here it is.
Note it is copyrighted.


/*
Solar Tracker
This program controls a servo to allow solar cells to always face the source of light
Created 1/18/11
Ian Bohannon
Copyright 2011
*/

#include <*servo.h>

int ServoOut = 9;
int photoPinLeft = 0;
int photoPinRight = 1;
int LeftReading;
int RightReading;
int pos;

Servo myservo;

void setup()
{
myservo.attach(ServoOut);
Serial.begin(9600);
}

void loop()
{
LeftReading = analogRead(photoPinLeft);
RightReading = analogRead(photoPinRight);

Serial.print("Left Reading = ");
Serial.println(LeftReading);
Serial.print("Right Reading = ");
Serial.println(RightReading);

if(LeftReading > RightReading)
{
pos = 65;
}
else if(LeftReading < RightReading)
{
pos = 45;
}
else
{
pos = 55;
}

myservo.write(pos);
delay(120);
}"


What it does is compare the light shining on each sensor, then through the If statement, adjusts the servo speed and direction accordingly. Through experimenting I know the servo sits still at position 55, spins one direction when higher than 55, and the other when lower than 55.

Because I can't upload it from this computer yet, I haven't gotten around to testing it and debugging it. The values may need to change a tad bit.

2 comments:

  1. A copyright! Linus Torvalds rolls in his grave... if he's dead.

    I'll be getting my arduino board here soon. My goal is to make an LED turn on. I'd better get my patent lawyer on the phone.

    ReplyDelete