EXPERIENCES
CODES ET COMPOSANTS
Plante Parle
​
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
int trig = 8;
int echo = 9;
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
void setup() { lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); }
void loop() {digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceInch = duration*0.0133/2;
if(distanceInch <70) {lcd.clear(); lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("ur far bb "); // Prints string "Distance" on the LCD lcd.print(distanceInch);lcd.print(" inch");lcd.setCursor(0,1); lcd.print("i need your love"); }else (distanceInch > 70);
{cd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed lcd.print("i feel u ") ; // Prints string "Distance" on the LCD lcd.print(distanceInch); lcd.print(" inch"); delay(10); lcd.setCursor(0,1); lcd.print("be gental"); }
}
Microservo
#include <Servo.h>int i = 0; int j = 0; int k = 0;
Servo servo_3;
void setup() {servo_3.attach(3);}
void loop()
{for (i = 0; i <= 180; i += 1) {servo_3.write(i); delay(50); }
for (k = 0; k >=180; k -= 1) { servo_3.write(k); delay(50);} for (j=0; j <= 120; j += 1) { servo_3.write(j); delay(50); } }
Test son
int Buzzer = 13;
void setup () {pinMode (Buzzer, OUTPUT); } void loop () //Main program loop
{digitalWrite (Buzzer, HIGH); // Buzzer will be on delay (7); // Waitmode for 4 seconds digitalWrite (Buzzer, LOW); //
Buzzer will be off
delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); //
Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); //
Buzzer will be off delay (5); //
Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); //
Buzzer will be off delay (7); //
Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); //
Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (7); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be offdelay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (7); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (7); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (7); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (5); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (2000); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (500); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (500); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (500); // Waitmode for another 2 seconds in which the buzzer will be off
digitalWrite (Buzzer, LOW); // Buzzer will be off delay (2000); // Waitmode for another 2 seconds in which the buzzer will be off
}
Test d'un objet crée a base d'aluminium, crayon, papier et scotch malléable et flexible
int f=13;
void setup() { // put your setup code here, to run once: pinMode(13,OUTPUT); }
void loop() { // put your main code here, to run repeatedly: digitalWrite(13,HIGH);}
Vision plante
​
#include <CapacitiveSensor.h>
CapacitiveSensor Sensor1 = CapacitiveSensor(4, 6);
CapacitiveSensor Sensor2 = CapacitiveSensor(8, 10);
long val1;
long val2;
int pos;
#define led 13
void setup()
{Serial.begin(9600);
pinMode(led, OUTPUT);}
​
void loop()
{val1 = Sensor1.capacitiveSensor(30);
val2 = Sensor2.capacitiveSensor(30);
Serial.print(val1);
Serial.print(" ");
Serial.print("\t");
Serial.print(val2);
Serial.print(" ");
Serial.print("\t");
Serial.println();
delay(2);
if (val1 >= 100 && pos == 0)
{digitalWrite(led, HIGH); pos = 1; delay(500); }
else if (val1 >= 100 && pos == 1)
{digitalWrite(led, LOW); pos = 0; delay(500);}
if (val2 >= 100 && pos == 0)
{digitalWrite(led, HIGH); pos = 1; delay(500); }
else if (val2 >= 100 && pos == 1)
{digitalWrite(led, LOW); pos = 0; delay(500); }
delay(10);}
​
Connections:
​
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.
The HC-SR04 sensor attach to the Breadboard
The Sensor VCC connect to the Arduino Board +5V
The Sensor GND connect to the Arduino Board GND
The Sensor Trig connect to the Arduino Board Digital I/O 9
The Sensor Echo connect to the Arduino Board Digital I/O 10
LCD Display Connection:
Before wiring the LCD screen to your Arduino or Genuino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen.
To wire your LCD screen to your board, connect the following pins:
LCD VSS pin to Arduino GND
LCD VDD pin to Arduino 5V
LCD VO pin to 10k Potentiometer center pin
LCD RS pin to digital pin 1
LCD RW pin to Arduino GND
LCD Enable pin to digital pin 2
LCD D4 pin to digital pin 4
LCD D5 pin to digital pin 5
LCD D6 pin to digital pin 6
LCD D7 pin to digital pin 7
The 10k Potentiometer's other legs connect to +5V and GNDpour le backlight du display, pin 15 (A+) and 16 (K-) de l’ LCD son connecté au +5V and GND
le LiquidCrystal library
​
Il permet de contrôler l’LCD displays qui sont compatible.
Il faut d'abord définir les broches Trig et Echo. Dans ce cas, il s'agit des broches numéro 9 et 10 sur la carte Arduino et elles sont nommées trigPin et echoPin. Ensuite, vous avez besoin d'une variable longue, appelée "duration" pour le temps de parcours que vous obtiendrez du capteur et une variable entière pour la distance.
Dans la configuration, on doit définir le trigPin comme une sortie et l'echoPin comme une entrée et également lancer la communication série pour afficher les résultats sur le moniteur série. Si l'objet se trouve à 10 cm du capteur et que la vitesse du son est de 340 m/s ou 0,034 cm/µs, l'onde sonore devra parcourir environ 294 u secondes. Mais ce qu'on obtient de la broche de l'écho sera le double de ce chiffre car l'onde sonore doit se déplacer vers l'avant et rebondir vers l'arrière. Donc, pour obtenir la distance en cm, nous devons multiplier la valeur du temps de parcours reçu de la broche de l'écho par 0,034 et la diviser par 2.
Patch sur Max 8 :
​
Aujourd'hui, ça permet d'envoyer des données au maximum à partir d'une carte Arduino externe sans avoir besoin de logiciels ou de bibliothèques supplémentaires. C'est très bien si vous voulez créer des manipulations vidéo fantaisistes basées sur des curseurs ou des capteurs externes. Dans le passé, on utilise des capteurs IR pour contrôler le mélange entre les shaders dans une installation interactive en utilisant exactement cette méthode ! dans notre cas la solution la plus facile est le renvoi de données dans Arduino pour contrôler les informations externes.
const char
DOUT_LED = 3;
int offset = 285; void setup()
{ Serial.begin(9600); pinMode(DOUT_LED,OUTPUT); } void loop() { int valeurSurA0 = analogRead(AN_PHOTORESISTANCE); int intensiteLED = 1023 - valeurSurA0; intensiteLED = intensiteLED - offset; if(intensiteLED<0) {intensiteLED=0;} Serial.println(intensiteLED); analogWrite(DOUT_LED, intensiteLED); delay(1); }