Why I love arduino...

... because an ignoramus like myself, who opens up his arduino box 3 times a year can make it sing!
It is just so easy, and so powerful

I recently wanted to monitor waves, from a model wave power generator that I set for my students as a practical activity.
Here it is:

(http://tinypic.com/view.php?pic=9qinup&s=7 if the image doesn't show)
An hour of code, an old til071 op amp and 4 resistors, an arduino and gobetwino and I was down the beach recording waves.
This has to be the great enabler for tinkerers - electronics for those who are not engineers, what linux was to computing but for electronics.

Truly, arduino rocks.
Science and Physics teachers take note!
Well done to developers.

// This sketch originally demonstrated the use of the Gobetwino commandtypes LGFIL and CPFIL
// It has been hacked about to log waves from the beach
//20 samples per second should be adequate to reconstruct a wave
// All blame to Leon Harris for this ugliness

// Hardware
// Arduino Duemilanova, 100x amplifier til071 based, coil of 100 turns of wire
// around a 25mm pvc pipe
// Use analogue pin 1 as input

int serInLen = 25;
char serInString[25];
int logValue1=0;
int logValue2=0;
int logValue3=0;
int result;
int sensorPin = A0;
int sensorValue = 0;

void setup()
{
// Setup serial comm. Initialize random function.
Serial.begin(9600);
randomSeed(analogRead(0));
delay(5000);
// Use the CPTEST copy file command to make a copy of a new empty logfile
Serial.println("#S|CPTEST|[]#");
readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}

void loop()
{
//Read a value off the analogue pin and log it

sensorValue = analogRead(sensorPin);
logData(sensorValue);
//delay(10); //wait 1/20th sec - timing is ugly
}

// Send the LOGTEST command to Gobetwino the 3 random values are seperated by semicolons

void logData( int value1)
{
char buffer[5];

Serial.print("#S|LOGTEST|[");
Serial.print(itoa((value1), buffer, 10));
Serial.println("]#");
readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}

//read a string from the serial and store it in an array
//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;

while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray = Serial.read();

  • i++;*
  • }*
    }
    Yes I know, timing sucks, and next time I will save to an array on the arduino before transfering by serial port, but even this gives me a good, usable wave

I agree wholeheartedly about the ease of use. I am so used to having to use difficult and complex APIs at work.

It just so nice to be able to make 20 lines of code actually do something really cool!