Beer pong : Différence entre versions
(→Equipe du projet) |
|||
| Ligne 16 : | Ligne 16 : | ||
*BRANDILY Hugo | *BRANDILY Hugo | ||
| − | [[Fichier: | + | [[Fichier:images.jpg]] |
==Liste du matériel== | ==Liste du matériel== | ||
| Ligne 28 : | Ligne 28 : | ||
==Étapes== | ==Étapes== | ||
*Créer un code | *Créer un code | ||
| + | |||
| + | #include <Adafruit_NeoPixel.h> | ||
| + | #define PIN 6 | ||
| + | |||
| + | int led = 2; | ||
| + | //int ruban = 10; | ||
| + | double photo = A0; | ||
| + | unsigned long previousMillis = 0; | ||
| + | |||
| + | Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800); | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | pinMode(led,OUTPUT); | ||
| + | //pinMode(ruban, OUTPUT); | ||
| + | pinMode(photo, INPUT); | ||
| + | |||
| + | strip.begin(); | ||
| + | strip.show(); // Initialise toute les led à 'off' | ||
| + | } | ||
| + | |||
| + | void all(int temps, int r, int v, int b) | ||
| + | { | ||
| + | for(int i = 0 ; i < 150 ; i++) | ||
| + | { | ||
| + | strip.setPixelColor(i, r, v, b); | ||
| + | } | ||
| + | strip.show(); | ||
| + | delay(temps); | ||
| + | } | ||
| + | |||
| + | double | ||
| + | etalonnage() | ||
| + | { | ||
| + | return analogRead(photo); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | unsigned long currentMillis = millis(); | ||
| + | double limit = etalonnage(); | ||
| + | limit-=10; | ||
| + | Serial.println(limit); | ||
| + | if(analogRead(photo)<limit) | ||
| + | { | ||
| + | delay(500); | ||
| + | while(analogRead(photo)<limit) | ||
| + | { | ||
| + | // La première valeur correspond au temps, la seconde à l'intensité du rouge, la troisième au vert, et la quatrième au bleu | ||
| + | all(1, 255, 255, 255); | ||
| + | tone(12,50,2000); | ||
| + | } | ||
| + | digitalWrite(led, HIGH); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
*Câbler l'ARDUINO | *Câbler l'ARDUINO | ||
| + | |||
| + | [[Fichier:arduino-1.jpg]] | ||
| + | |||
| + | |||
*Câbler le ruban de LED | *Câbler le ruban de LED | ||
Version du 18 janvier 2019 à 16:09
Description du projet
Un jeu de beer pong nouvelle génération. Un dispositif ludique pour vous aider même après 3 grammes dans le sang.
Chaque balle qui entre dans un verre l'illumine pour qu'il soit repéré et émet un son.
Equipe du projet
- GOURPIL Jossua
- GUIGHOUX Robin
- JOLY Leopold
- BRANDILY Hugo
Liste du matériel
- Red cup
- Ruban de LED
- Résistance photovoltaïque
- ARDUINO
- Carte LABDEC
- Haut parleur
Étapes
- Créer un code
- include <Adafruit_NeoPixel.h>
- define PIN 6
int led = 2; //int ruban = 10; double photo = A0; unsigned long previousMillis = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600); pinMode(led,OUTPUT); //pinMode(ruban, OUTPUT); pinMode(photo, INPUT);
strip.begin(); strip.show(); // Initialise toute les led à 'off'
}
void all(int temps, int r, int v, int b) {
for(int i = 0 ; i < 150 ; i++)
{
strip.setPixelColor(i, r, v, b);
}
strip.show();
delay(temps);
}
double etalonnage() {
return analogRead(photo);
}
void loop() {
unsigned long currentMillis = millis();
double limit = etalonnage();
limit-=10;
Serial.println(limit);
if(analogRead(photo)<limit)
{
delay(500);
while(analogRead(photo)<limit)
{
// La première valeur correspond au temps, la seconde à l'intensité du rouge, la troisième au vert, et la quatrième au bleu
all(1, 255, 255, 255);
tone(12,50,2000);
}
digitalWrite(led, HIGH);
}
}
- Câbler l'ARDUINO
- Câbler le ruban de LED



