TODO
push.sh
+libraries/aero/
int bluePin = 9;
//uncomment this line if using a Common Anode LED
-//#define COMMON_ANODE
+#define COMMON_ANODE
void setup()
{
http://arduino.cc/en/Tutorial/AnalogInput
+ Schema: http://lab.piffa.net/schemi/potenziometro_bb.png
+
*/
int sensorPin = A0; // select the input pin for the potentiometer
R = (5v-1.8v) / 0.010a
R =320ohms
- This example code is in the public domain.
+
+ Schema: http://lab.piffa.net/schemi/led_single_bb.png
+ - http://lab.piffa.net/schemi/led_single_schem.png
+
+ This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
--- /dev/null
+/* Joystick
+Utilizzo di un joystick analogico con arduino.
+da: http://42bots.com/tutorials/arduino-joystick-module-example/
+
+Il joystich ha 2 potenziometri analogici e un interruttore digitale
+corrispondente alla pressione dello stick (input momentaneo).
+
+ */
+int xPin = A1;
+int yPin = A0;
+int buttonPin = 2;
+
+int xPosition = 0;
+int yPosition = 0;
+int buttonState = 0;
+
+void setup() {
+ // initialize serial communications at 9600 bps:
+ Serial.begin(9600);
+
+ pinMode(xPin, INPUT);
+ pinMode(yPin, INPUT);
+
+ //activate pull-up resistor on the push-button pin
+ pinMode(buttonPin, INPUT_PULLUP);
+
+ // For versions prior to Arduino 1.0.1
+ // pinMode(buttonPin, INPUT);
+ // digitalWrite(buttonPin, HIGH);
+
+}
+
+void loop() {
+ xPosition = analogRead(xPin);
+ yPosition = analogRead(yPin);
+ buttonState = digitalRead(buttonPin);
+
+ Serial.print("X: ");
+ Serial.print(xPosition);
+ Serial.print(" | Y: ");
+ Serial.print(yPosition);
+ Serial.print(" | Button: ");
+ Serial.println(buttonState);
+
+ delay(100); // add some delay between reads
+}
\ No newline at end of file
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
-
+
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
//////////////
// Second LED
int ledB = 12; //Secondo LED
-int ledStateB = LOW; // ledState used to set the LED
+ // ledState used to set the LED
long previousMillisB = 0; // will store last time LED was updated
-long intervalB = 500; // interval at which to blink (milliseconds)
+ // interval at which to blink (milliseconds)
void setup() {
}
void lightLedB () {
+ long intervalB = 500;
+ static int ledStateB ;
if(millis() - previousMillisB > intervalB) {
// save the last time you blinked the LED
previousMillisB = millis();
/* Approfondimenti
- integrazione tra funzioni e dati: programmazione a oggetti
- - Uso di pointers per modificare dati esterni allo scope della funzione
+ - Uso di pointers per modificare dati esterni allo scope della funzione, static
- Uso di forme di dati strutturate (array, struct) per scambiare dati tra funzioni e programma
*/
Serial.println(a > b);
Serial.print("a < b = "); // minore
- Serial.println(a < c);
+ Serial.println(a < b);
Serial.print("a == b -> "); // stesso valore
Serial.println(a == b);
Serial.println(a != b);
Serial.print("a <= b ->"); // minore uguale
- Serial.println(b <= a);
+ Serial.println(a <= b);
Serial.print("a >= b -> "); // maggiore uguale
- Serial.println(b >= a);
+ Serial.println(a >= b);
}
void loop() // we need this to be here even though its empty