It’s eons since I messed with an Arduino, and I’ve forgotten it all. All I have handy is a Duemilanove with ATmega168 and the newish version of the Arduino IDE doesn’t have Duemilanove ATmega168 as an option. Following this otherwise perfect tutorial and with IDE 1.6.1 (which works even though it’s for Java 6 and I have Java 8 on this mac), you get this error if you choose just Duemilanove:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
[...]
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
But it’s fine if you choose “Arduino NG or older” in tools > board, like this:

The other difference is that these days, you don’t have to reboot after installing the FTDI drivers.
Once I have blink worked, I moved to this servo tutorial, since I have a tiny micro servo 9g from somewhere (Richard?).

In that tutorial it says you need to download and add the servo library; in fact it’s already there in “sketch > import library”.
Initially I got
Arduino: 1.6.1 (Mac OS X), Board: "Arduino NG or older, ATmega168"
Build options changed, rebuilding all
servo1.ino: In function 'void loop()':
servo1.ino:46:3: error: 'refresh' is not a member of 'Servo'
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
The tutorial is evidently very out of date with respect to the servo library – this fixed it (and hi Anachrocomputer in that thread!)
From the processing code in that tutorial:
//Output the servo position ( from 0 to 180)
port.write("s"+spos);
using the serial monitor (set to 19200 baud rate) I should be able to input “s100” in the serial monitor and have the servo move. But nothing happened. So I put some more logging in, and saw garbled stuff or nothing, and I wondered if my arduino is too old to do that baud rate. Doing this it reverses “foo” to “oof” but who knows.
Anyway, a few things:
firstly the code refers to the second servo, so the pin needs to be in analogue 2 not 1?
secondly, the serial monitor seems happier with line endings enabled
thirdly, and the actual problem turns out I had the pin wrong – that tutorial is very out of date, or the library’s changed a lot, or something. What you need is one of these, e.g digital 9.
Here’s the way I got it going.
Use this code:
// Sweep
// by BARRAGAN
// This example code is in the public domain.
#include
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
and the digital 9 pin as in the diagram on that page. Arduino pin naming seems nearly as confusing as the Raspberry Pi’s.
I think this little servo might be a bit noisy for what I have in mind, but it’s nice to have it working.
