Projet Transmission Laser

Bonjour,

je suis tout nouveau dans le coin, donc j'ai plein de questions !

j'ai vu pas mal de projet de laser tag utilisant l'infrarouge, mais cela ne m'intéresse pas. Je veux pouvoir garder une certaine précision!
j'ai trouvé ça sur le net Weekend Project: Make a Simple Laser Communicator - YouTube

d'après vous, serait il possible de transmettre de la même façon, des trames de laser codé en séquence de 5 à 10 octets pour éviter les bugs, de les recevoir sur l'arduino et d'exécuter une action ?

je précise ^^

Je pense faire 2 ou 3 octets d'initialisation, phase pendant laquelle le arduino s'apprête à recevoir une info "111", ensuite l'info "0010", et l'octet de fin 1.
Donc, je dirige mon laser vers un capteur (phototransistor, autre ?), mon laser fait 11100101, et la mon arduino sait que lorsqu'il lis 11100101 il allume une led.

Par contre si mon laser fait 11101101, la il allume une seconde led ou actionne quelque chose.

Est ce que je peux brancher une sortie analogique de la même façon qu'ils utilisent le jack avec le son ? sauf que j'enverrai des salves de 111001011110010111100101111001011110010111100101 ^^

aussi seconde chose ^^ est ce possible de le faire avec 1 seul arduino ? sera t il capable de gérer l'entrée et la sortie ?

par exemple si je tire sur mon arduino est ce qu'il pourra le savoir ? ^^

merci d'avance pour toute l'aide que vous pourrez m'apporter !

bonne nuit aux insomniaques !

Tout est possible avec l'arduino ^^

Oui je pense que ton projet est totalement faisable, et de surcroit avec une seule arduino. Ton code bouclerait sur la partie "captation sonore" et il y aurait une interruption sur la partie laser. Après il faut voir si la transmission laser est fiable, avec un débit satisfaisant, éliminer les perturbations etc ...

oki ^^

j'attends de recevoir tout le matos pour m'y mettre plus sérieusement!
il n'y a qu'avec les tests que je serai fixé de toute façon...

Pour les parasites ça m'inquiete pas trop car ça se jouerai dans la nuit, donc pas de problème!

je suis entrain de voir du coté des protocoles de fibre optique... peut être que je trouverai une piste!

j'ai tout ce qu'il me faut je m'y mets demain et ce weekend!
si vous avez des idées pour y arriver je suis preneur :smiley:
merci d'avance :wink:

Bonjour cereal,
Tu peux utiliser la librairie Virtual Wire elle fait le boulot pour les transmissions radio, c'est idem pour ton laser.

A+ Teiva

yes nickel! je vais regarder ça! merci!

bon, je fais tout par module que je vais assembler au fur et à mesure...

Pour l'instant j'écris juste le numéro du gilet, et à chaque fois que le gilet est touché, ça marque +1, jusque là c'est pas compliqué ^^
dés que j'essaye de rajouter un nombre de vie limité à 20, avec l'affiche de GameOver, dés la première touche le logiciel écrit GameOver...

Si vous avez des idées...

j'ai lu et essayé de comprendre le fonctionnement des fonctions mais la je seche ^^

merci d'avance

voici le code :

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 8; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int GameOver = 20; // le nombre de vie

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // variable for reading the pushbutton status
int lastButtonState = 0; // previous state of the button

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num xx");
}

void loop(){

// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
lcd.setCursor(0, 1);
lcd.print("Dead:");
lcd.print(buttonPushCounter, DEC);

// compare le score en cours avec le score de fin de partie
if (buttonPushCounter == 20)
lcd.setCursor(8, 1);
lcd.print("GameOver");

}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

}

C'est bon j'ai réussi! ^^
j'ai pas mal avancé!

maintenant quand je tire avec le laser sur le photorésistor,l y a un flash, il me dit cible avant pendant 4sec, et revient sur l'écran de départ avec +1 d'incrémentation!

maintenant encore une question (avant que je ne trouve tout seul ^^), comment faire pour avoir une formule du type :

Attendre...
ou
(Si ça, faire ça)
ou
(Si ça, faire ça)

résultat final, +1 incrémentation du compteur

en langage français ça donne,
le arduino attend que je tire sur la cible 1 ou la cible 2 et en fonction de celle qui est touché, il enchaine leur code respectif, pour au final revenir à l'état de départ +1 d'incrémentation

merci d'avance!!

voici mon code pour vous montrer ou je suis bloqué :

// constants won't change. They're used here to
// set pin numbers:
const int lightPin0 = 0; // Cible n°1 Avant
const int lightPin1 = 1; // Cible n°2 Arrière
const int ledPin0 = 13; // Lumière Cible n°1
const int ledPin1 = 8; // Lumière Cible n°2

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // variable for reading the pushbutton status
int lastButtonState = 0; // previous state of the button
int threshold = 250;

void setup() {
Serial.begin(9600); //Begin serial communication
// initialize the LED pin as an output:
pinMode(ledPin0, OUTPUT);
// Lumière cible avant en OUTPUT
pinMode(ledPin1, OUTPUT);
// Lumière cible arrière en OUTPUT
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");
}

void loop(){

// compare la valeur de la résistance du photorésistor de "Cible n°1 Avant"
if (analogRead(lightPin0) > threshold) {
// Si l'état a changé, incrémenter le compteur
digitalWrite(13, LOW);
// if the current state is HIGH then the button
// wend from off to on:

lcd.setCursor(0, 1);
lcd.print("Dead:");
lcd.print(buttonPushCounter);

}
else {
digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
lcd.begin(16, 2);
lcd.print("cible avant");
delay(4000);
buttonPushCounter++;
lcd.print(buttonPushCounter);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}
}

ça serait pas Else If ma fonction ??

bonjour!

j'ai beau chercher je trouve pas :frowning:
ça bloque m'exécute que la première instruction...

voici ou en est mon code :

// constants won't change. They're used here to
// set pin numbers:
const int lightPin0 = 0; // Cible n°1 Avant
const int lightPin1 = 1; // Cible n°2 Arrière
const int ledPin0 = 13; // Lumière Cible n°1
const int ledPin1 = 8; // Lumière Cible n°2

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // variable for reading the pushbutton status
int lastButtonState = 0; // previous state of the button
int threshold = 250;

void setup() {
Serial.begin(9600); //Begin serial communication
// initialize the LED pin as an output:
pinMode(ledPin0, OUTPUT);
// Lumière cible avant en OUTPUT
pinMode(ledPin1, OUTPUT);
// Lumière cible arrière en OUTPUT
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");
}

void loop()
{
// compare la valeur de la résistance du photorésistor de "Cible n°1 Avant"
if (analogRead(lightPin0) > threshold)
if (analogRead(lightPin1) > threshold)
{

digitalWrite(8, LOW);
digitalWrite(13, LOW);
// if the current state is LOW then the button
// wend from off to on:

lcd.setCursor(0, 1);
lcd.print("Dead:");
lcd.print(buttonPushCounter);
}
else if (analogRead(lightPin0) > threshold)
{
digitalWrite(8, HIGH);
delay(150);
digitalWrite(8, LOW);
lcd.begin(16, 2);
lcd.print("cible avant");
delay(4000);
buttonPushCounter++;
lcd.print(buttonPushCounter);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}
else if (analogRead(lightPin1) > threshold)
{
digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
lcd.begin(16, 2);
lcd.print("cible arriere");
delay(4000);
buttonPushCounter++;
lcd.print(buttonPushCounter);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}
}
merci d'avance!

aaaaaaaaaaaah!

j'en vois le bout ^^

ça à l'air de fonctionner !!

// constants won't change. They're used here to
// set pin numbers:
const int lightPin0 = 0; // Cible n°1 Avant
const int lightPin1 = 1; // Cible n°2 Arrière
const int ledPin0 = 13; // Lumière Cible n°1
const int ledPin1 = 8; // Lumière Cible n°2

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // variable for reading the pushbutton status
int lastButtonState = 0; // previous state of the button
int threshold = 100;

void setup() {
Serial.begin(9600); //Begin serial communication
// initialize the LED pin as an output:
pinMode(ledPin0, OUTPUT);
// Lumière cible avant en OUTPUT
pinMode(ledPin1, OUTPUT);
// Lumière cible arrière en OUTPUT
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}

void loop()

{
if (analogRead(lightPin0) > threshold)
{
digitalWrite(8, LOW);
digitalWrite(13, LOW);
// if the current state is LOW then the button
// wend from off to on:

lcd.setCursor(0, 1);
lcd.print("Dead:");
lcd.print(buttonPushCounter);
}
else if (analogRead(lightPin0) < threshold)
{
digitalWrite(8, HIGH);
delay(150);
digitalWrite(8, LOW);
lcd.begin(16, 2);
lcd.print("cible avant");
delay(4000);
buttonPushCounter++;
lcd.print(buttonPushCounter);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}
if (analogRead(lightPin1) > threshold)
{
digitalWrite(8, LOW);
digitalWrite(13, LOW);
// if the current state is LOW then the button
// wend from off to on:

lcd.setCursor(0, 1);
lcd.print("Dead:");
lcd.print(buttonPushCounter);
}
else if (analogRead(lightPin1) < threshold)
{
digitalWrite(13, HIGH);
delay(150);
digitalWrite(13, LOW);
lcd.begin(16, 2);
lcd.print("cible arriere");
delay(4000);
buttonPushCounter++;
lcd.print(buttonPushCounter);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Gilet num 1");

}
}

Bon, maintenant j'arrive à différencier la cible 1 de la cible 2, et écrire un message en conséquence.

Je cherche maintenant à faire trois choses (quand je n'arrive pas sur une je commence une autre et dés que mon cerveau veut bien reprendre je reviens dessus^^ ça marche pas mal!) :

la première, ma boucle ne commence pas tant que je n'ai pas appuyé sur un bouton...
j'ai essayé pas mal de chose et ça ne fonctionne pas! j'arrive juste à allumer la led en appuyant sur un bouton ^^

ensuite, j'aimerai faire un compte à rebours qui commence à 100% (20min), et qui descend au fur et à mesure jusqu'à 0% (0min)
la pareil j'ai essayé pas mal de chose mais ça ne fonctionne pas :confused:

j'arrive juste à compter les secondes 1 2 3 ...

La troisième, j'aimerai stocker une valeur qui s'incrémente, pour la ressortir plus tard.
Je m'explique, j'ai un compteur de "Dead = x fois" j'aimerai qu'à la fin de la partie, le arduino marque sur l'écran x fois Avant, X fois Arrière.

je vais bien sur continuer à chercher de mon côté,

mais si vous avez des idées je suis preneur !

merci d'avance

help! je patauge! =( :blush:
merci :slight_smile: