Modifications

Radio Vintage Interfacée

6 568 octets ajoutés, 19 juin 2014 à 08:27
aucun résumé de modification
[[Fichier:{{Projet|status=Experimental|image=Radio_vintage.png]]{{Projet|name=Radio Vintage Interfacée|description=Radio Vintage Interfacée avec un arduino et plein d'autres trucs
|contributeurs=Julien Merlaud
|ingrédients=eclectronique
}}
 
 
[[Fichier:Radio_vintage.png]]
A partir de ce vieux poste Radio, je récupère les commandes de l'appareils pour piloter un arduino et d'autres appareils d'éclairages, sonores type walkman.
Deux potentiomètres sont glissés derrière la façade.
[[Fichier:Radio_pot.png]]
L'occasion de bricoler un peu et de tester les librairies arduino, voire les compatibilités avec Processing.
<code>
}
 
</code>
 
29 avril 2014 :
 
J'effectue des recherches dans les librairies de Processing, pour permettre à cette radio de jouer une trentaine de sons préenregistrés en fonction de la station choisi.
 
Ici des ressources sur la librairie Minim : [http://code.compartmental.net/minim/javadoc/]
 
Plusieurs codes à tester.
 
En fin de compte, je choisi de changer simplement d'arduino et d'utiliser un modèle Léonardo qui gère la fonction KeyboardPrint, un peu long pour moi de prendre en main la communication serial, processing.. Je choisi du presque tout fait via cette fonction arduino qui permet d'émuler un clavier USB. Ainsi, les valeurs du potentiomètre de 0 à 1023 renverront par secteur à une lettre, l'ordi recevra l'instruction comme ça et je n'ai plus à utiliser qu'un logiciel tout fait comme SoundPlant sur lequel chaque touche clavier déclenche un son :
 
[[Fichier:SoundPlantInterfaceVisuel.png]]
 
 
 
et voici le code que nous avons développé, attention une partie vous allez vite le voir correspond à la gestion d'un servomoteur connecté à un autre bouton de la radio.
 
 
<code>
 
#include <Servo.h>
 
Servo myServo1;
Servo myServo2;// create a servo object
 
int const potPin2 = A2; // analog pin used to connect the potentiometer
int const potPin3 = A3;
int potVal2;
int potVal3;// variable to read the value from the analog pin
int angle; // variable to hold the angle for the servo motor
int ValeurBlocage; // variable utilisée pour controler si le potard bouge
int ValeurPotard;// valeur du potard
int ValeurLatence; // pour contrer le bruit sur le potard
void setup() {
myServo1.attach(10);
//myServo2.attach(12); // attaches the servo on pin 9 to the servo object
Serial.begin(9600); // open a serial connection to your computer
Keyboard.begin();
}
 
void loop() {
potVal2 = analogRead(potPin2); // read the value of the potentiometer
// print out the value to the serial monitor
//Serial.print("potVal2: ");
//g
//Serial.print(potVal2);
 
// scale the numbers from the pot
angle = map(potVal2, 0, 1023, 20, 150);
 
// print out the angle for the servo motor
//Serial.print(", angle: ");
//Serial.println(angle);
 
// set the servo position
myServo1.write(angle);
 
// wait for the servo to get there
delay(100);
 
//myServo2.attach(12); // attaches the servo on pin 9 to the servo object
//Serial.begin(9600); // open a serial connection to your computer
 
//potVal3 = analogRead(potPin3); // read the value of the potentiometer
// print out the value to the serial monitor
//Serial.print("potVal3: ");
//Serial.print(potVal3);
 
// scale the numbers from the pot
//angle = map(potVal3, 0, 1023, 20, 150);
 
// print out the angle for the servo motor
//Serial.print(", angle: ");
//Serial.println(angle);
 
// set the servo position
//myServo2.write(angle);
 
// wait for the servo to get there
//delay(100);
 
potVal3= analogRead(potPin3);
/* if (potVal3>= (ValeurLatence+10) && potVal3<= ValeurLatence+10)
{
ValeurPotard=potVal3;
}
*/
ValeurPotard=potVal3;
Serial.print("valeurLatence");
Serial.print(ValeurLatence);
Serial.println();
Serial.print(" valeurPotard");
Serial.print(potVal3);
Serial.println();
Serial.print("valeurBlocage");
Serial.print(ValeurBlocage);
Serial.println();
Serial.print(" valeur");
Serial.print(ValeurPotard);
Serial.println();
delay(100);
while (ValeurBlocage!=ValeurPotard)
// lz bloc s'effectue uniquement si la valeur de blocage est différente de la valeur du pot3
{
Serial.print("DansBoucle While");
delay(100); // chaque 1 seconde relance
if (ValeurPotard>(ValeurLatence+10)|| ValeurPotard<ValeurLatence-10) // la double barre représente un ou logique
{
Serial.print("DansBoucle if");
if (potVal3>= 690 && potVal3<= 710)
Keyboard.println("1");
 
if (potVal3>= 670 && potVal3<=689)
Keyboard.println("2");
if (potVal3> 650 && potVal3<= 669)
Keyboard.println("3");
if (potVal3>= 630 && potVal3<=649)
Keyboard.println("4");
if (potVal3>= 610 && potVal3<=629)
Keyboard.println("5");
if (potVal3>= 590 && potVal3<=609)
Keyboard.println("6");
if (potVal3>= 570 && potVal3<=589)
Keyboard.println("7");
if (potVal3>= 550 && potVal3<=569)
Keyboard.println("8");
if (potVal3>= 530 && potVal3<=549)
Keyboard.println("9");
if (potVal3>= 510 && potVal3<=529)
Keyboard.println("0");
if (potVal3>= 490 && potVal3<= 509)
Keyboard.println("1");
if (potVal3>= 470 && potVal3<=489)
Keyboard.println("2");
if (potVal3> 450 && potVal3<= 469)
Keyboard.println("3");
if (potVal3>= 430 && potVal3<=449)
Keyboard.println("4");
if (potVal3>= 410 && potVal3<=429)
Keyboard.println("5");
if (potVal3>= 390 && potVal3<=409)
Keyboard.println("6");
if (potVal3>= 370 && potVal3<=389)
Keyboard.println("7");
if (potVal3>= 350 && potVal3<=369)
Keyboard.println("8");
if (potVal3>= 330 && potVal3<=349)
Keyboard.println("9");
if (potVal3>= 310 && potVal3<=329)
Keyboard.println("0");
if (potVal3>= 290 && potVal3<= 309)
Keyboard.println("q");
if (potVal3>= 270 && potVal3<=289)
Keyboard.println("s");
if (potVal3> 250 && potVal3<= 269)
Keyboard.println("d");
if (potVal3>= 230 && potVal3<=249)
Keyboard.println("f");
if (potVal3>= 210 && potVal3<=229)
Keyboard.println("g");
if (potVal3>= 190 && potVal3<=209)
Keyboard.println("h");
if (potVal3>= 170 && potVal3<=189)
Keyboard.println("j");
if (potVal3>= 150 && potVal3<=169)
Keyboard.println("k");
if (potVal3>= 130 && potVal3<=149)
Keyboard.println("l");
if (potVal3>= 110 && potVal3<=129)
Keyboard.println("m");
if (potVal3>= 90 && potVal3<=109)
Keyboard.println("n");
if (potVal3>= 70 && potVal3<=89)
Keyboard.println("n");
if (potVal3>= 50 && potVal3<=69)
Keyboard.println("b");
if (potVal3>= 30 && potVal3<=49)
Keyboard.println("v");
if (potVal3>= 0 && potVal3<=29)
Keyboard.println("c");
 
}
ValeurBlocage=ValeurPotard;
ValeurLatence=ValeurPotard;
}
 
 
}
 
 
 
 
</code>
 
 
Et voici la Radio sur laquelle une plaque spéciale Festival D a été installée :
 
[[Fichier:RadioMAJ.JPG]]