#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math. #include // Includes the PulseSensorPlayground Library. // Variables const int PulseWire = 2; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0 int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore. // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.ete // Otherwise leave the default "550" value. PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor" int PinPotRot = A4; // pin du potar rotatif int PinPotLin = A1; // pin du potar lineaire int PinBouton = A3; // pin du send button float degree = 0.0; // tension recu par le potar rot float intensite = 0.0; // tension recu par le potar lin int emotion = 0; // nom de l'emotion envoyée int time; bool etatBouton = false; // etat du bouton d'envoi void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(PinBouton, INPUT); // Configure the PulseSensor object, by assigning our variables to it. pulseSensor.analogInput(PulseWire); pulseSensor.setThreshold(Threshold); // Double-check the "pulseSensor" object was created and "began" seeing a signal. if (pulseSensor.begin()) { Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset. } } void loop() { // put your main code here, to run repeatedly: //Serial.println(analogRead(PinBouton)); int etatBouton = analogRead(PinBouton); int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int". // "myBPM" hold this BPM value now. //affiche dans le serial toutes les données récoltées if (etatBouton == 1023){ Serial.print(millis()/1000); Serial.print(", emotion :"); Serial.print(emotion); Serial.print(", intensité : "); Serial.println(intensite); } delay(200); degree = map(analogRead(PinPotRot), 0, 1024, 1, 16); //decompose le cadran en 16 parties potRot(); potLin(); if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened". //Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened". Serial.print("BPM: "); // Print phrase "BPM: " Serial.println(myBPM); // Print the value inside of myBPM. } } void potLin(){ // fonction pour le potentiometre lineaire intensite = map(analogRead(PinPotLin), 0, 1024, 0, 6); // decompose la jauge d'int avec 5 crans } void potRot(){ // fonction pour le potentiometre rotatif degree = map(analogRead(PinPotRot), 0, 1024, 0, 16); // decompose le cadran en 16 parties ////////////////////////// nommage de chacune des 16 parties /////////////////// if (degree >= 0 && degree < 1){ //emotion = "fierté"; emotion = 1; } if (degree >= 1 && degree < 2){ //emotion = 'allegresse'; emotion = 2; } if (degree >= 2 && degree < 3){ //emotion = 'joie'; emotion = 3; } if (degree >= 3 && degree < 4){ //emotion = 'satisfaction'; emotion = 4; } if (degree >= 4 && degree < 5){ //emotion = 'soulagement'; emotion = 5; } if (degree >= 5 && degree < 6){ //emotion = 'espoir'; emotion = 6; } if (degree >= 6 && degree < 7){ //emotion = 'interêt'; emotion = 7; } if (degree >= 7 && degree < 8){ //emotion = 'surprise'; emotion = 8; } if (degree >= 8 && degree < 9){ //emotion = 'tristesse'; emotion = 9; } if (degree >= 9 && degree < 10){ //emotion = 'peur'; emotion = 10; } if (degree >= 10 && degree < 11){ //emotion = 'honte'; emotion = 11; } if (degree >= 11 && degree < 12){ //emotion = 'culpabilité'; emotion = 12; } if (degree >= 12 && degree < 13){ //emotion = 'envie'; emotion = 13; } if (degree >= 13 && degree < 14){ //emotion = 'dégout'; emotion = 14; } if (degree >= 14 && degree < 15){ //emotion = 'mepris'; emotion = 15; } if (degree >= 15){ //emotion = 'colere'; emotion = 16; } /////////////////////////////////////////////// }