23
ARDUINO

ARDUINO - Weeblyanarchitects.weebly.com/uploads/3/8/6/6/38662121/arduino.pdf · charger S4Afirmware16.uno sur l’arduino scratch prend le contrôle. Température LM35 1€ ... RFID

  • Upload
    ngothuy

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

ARDUINO

Hardware : arduino UNO 8€2005, Atmel/ATmega, 32k, 16Mhz, http://arduino.cc/en/Main/Products

Arduino IDEhttp://arduino.cc/en/main/software

C++

BareMinimumvoid setup() {

// put your setup code here, to run once:

}

void loop() {

// put your main code here, to run repeatedly:

}

Bread board

Led blink (100 pour 2€)void setup() {

// initialize digital pin 13 as an output.

pinMode(13, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

Led FadePulse Width Modulationint led = 9; // the pin that the LED is attached toint brightness = 0; // how bright the LED isint fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT);}

// the loop routine runs over and over again forever:void loop() { // set the brightness of pin 9: analogWrite(led, brightness);

// change the brightness for next time through the loop: brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); }

Scratch with Arduino = S4Ahttp://s4a.cat/

charger S4Afirmware16.uno sur l’arduino

scratch prend le contrôle

Température LM35 1€void loop(){

int temp = analogRead(inputPin);

float millivolts = (temp / 1024.0) * 500;

int celsius = millivolts; // sensor output is 10mV per degree Celsius

Serial.println(celsius);

delay(delaySend);

}

Utilisation de donnéesPython, Go, Java, C, ...

Choix python librairie Pyserial la plus utilisée

sudo easy_install -U pyserial

http://playground.arduino.cc/Interfacing/Python

Programme Pythonimport sys

import serial

devArduino='/dev/tty.usbmodem1421'

try:

ser = serial.Serial(devArduino, 9600)

except:

print 'Arduino not found --> ', sys.exc_info()[1]

exit(0)

print ser

while 1 :

input=ser.readline()

print input

print 'serial closed'

ser.close

InfluxDBTime series database

influxdb -config=/usr/local/etc/influxdb.conf

http://localhost:8083/ (root/root)

list series;

select * from TEMP01;

select * from TEMP01 where time > now() - 1h;

Call rest python to influxDB

https://github.com/influxdb/influxdb-python

easy_install influxdb

Ajout dans le programmehost='localhost'

port = 8086

user = "root"

password = "root"

db_name = "probes"

db = influxdb.InfluxDBClient(host, port, user, password)

db.switch_db(db_name)

series = db.query("list series;")

print "series: {0}".format(series)

print 'Connection to InfluxDB\n'

------

json_body = [{ "points":[[value]], "name":key, "columns":["value"]}]

db.write_points_with_precision(json_body, time_precision='u')

UI VocalGet last temperature from InfluxDB

Javascript

Gauge

Text to command

Google to speech

Basic itemsBreadboard : 2€Fils : 2€

Resistances 400 pour 3€

InputJoystick : x,y et push 2€Keypad : clavier chiffres, lettres 0,5€Boutons : 50 pour 3€Telecommande : 2€Potentiometre : 1€

SensorEau 1€Feu 1€CO 2€Distance par ultrason 1€InfrarougeRFIDLigthTiltTemperatureHumiditéPressionPrésenceContact

MoteurMoteur pas à pas 1€Moteur On/Off Moteur servo : x degrés

DisplayLed one color : 100 pour 2 €Led RGB : 1€Led strip RGB 5m 13€LCD 3€Led infrarouge : 10 pour 1€MatriceCiphers

Relay1 realy 220V 1€

SonBuzer

CartesCarte RJ45 + SD : 15€Carte prototype : 3€

Communication Wireles 2€Pas encore testé433 Mhz (EU Ok)Pas cher100mTélécommande

Atmega microcontrolleur standalone