Buongiorno a tutti,
Avrei un quesito urgente da sottoporvi.
Ho acquistato Arduino2009 per utilizzarlo per il progetto di maturità, consistente in un rilevatore di temperatura il quale manda i dati ad Arduino il quale dovrebbe mandare i valori rilevati ad un file di testo.
Partiamo dal presupposto che devo ancora cercare come svolgere queste parti, e degli esempi già svolti mi risulterebbero molto utili.
Il problema di cui volevo principalmente parlarvi, tuttavia, è un altro: per provare Arduino con Processing, ho trovato un esempio consistente nell'accensione di un led. Di seguito il codice:
Parte Arduino
/*Arduino Code
- Switch an LED on
- —————–
- turns on an LED when receiving an “A” character with any serial software
*Code modified by Francesco Saitta
*
- Code originally created 1 June 2005
- copyleft 2005 DojoDave
- based on an orginal by H. Barragan for the Wiring i/o board
*/
int ledPin = 13; // LED connected to digital pin 13
int val = 0;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
}
void loop()
{
val = Serial.read();
if (val == 'A') {
digitalWrite(ledPin, HIGH); // sets the LED on
delay(10000);
}
if (val == 'a') {
digitalWrite(ledPin, LOW); // sets the LED off
}
}
Parte Processing:
// Processing code
// Example by Tom Igoe
import processing.serial.;
import cc.arduino.;
// The serial port:
Serial myPort;
// List all the available serial ports:
println(Serial.list());
// Note from Tom Igoe
// I know that the first port in the serial list on my mac
// is always my Keyspan adaptor, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[1], 9600);
// Send a capital A out the serial port
myPort.write(65);
Il problema è che il Led non si accende (Sì, l'ho collegato al Pin 13).
Qualcuno sa come potrei risolvere il problema?