first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

119
AnalogInput/AnalogInput.ino Normal file
View File

@@ -0,0 +1,119 @@
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on the value obtained
by analogRead().
The circuit:
- potentiometer
center pin of the potentiometer to the analog input 0
one side pin (either one) to ground
the other side pin to +5V
- LED
anode (long leg) attached to digital output 13
cathode (short leg) attached to ground
- Note: because most Arduinos have a built-in LED attached to pin 13 on the
board, the LED is optional.
created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A3; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
float sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
// sensorValue = 0;
// int bcl = 75;
// for (int i=1; i <bcl; i++) {
// sensorValue += analogRead(sensorPin);
// delay(1);
// }
int number_of_samples = 50;
long sum_squared_voltage = 0;
for (int n=0; n<number_of_samples; n++)
{
// inst_voltage calculation from raw ADC input goes here.
int inst_voltage = analogRead(A3) - 512;
long squared_voltage = inst_voltage * inst_voltage;
sum_squared_voltage += squared_voltage;
// delay(20);
}
double mean_square_voltage = sum_squared_voltage / number_of_samples;
double root_mean_square_voltage = sqrt(mean_square_voltage);
//
// sensorValue = analogRead(sensorPin);
// Serial.print(sensorValue - 512);
// Serial.print(mean_square_voltage);
// Serial.print(" V2 ");
Serial.print(root_mean_square_voltage);
Serial.println(" V ");
// long sum_squared_current = 0;
//
// for (int n=0; n<number_of_samples; n++)
// {
// // inst_current calculation from raw ADC input goes here.
// int inst_current = analogRead(A5) - 512;
//
// long squared_current = inst_current * inst_current;
//
// sum_squared_current += squared_current;
// }
//
// double mean_square_current = sum_squared_current / number_of_samples;
// double root_mean_square_current = sqrt(mean_square_current);
//
// Serial.print(root_mean_square_current);
// Serial.println(" A ");
// sum_squared_current = 0;
//
// for (int n=0; n<number_of_samples; n++)
// {
// // inst_current calculation from raw ADC input goes here.
// int inst_current = analogRead(A5) - 512;
//
// long squared_current = inst_current * inst_current;
//
// sum_squared_current += squared_current;
// }
//
// mean_square_current = sum_squared_current / number_of_samples;
// root_mean_square_current = sqrt(mean_square_current);
//
// Serial.print(root_mean_square_current);
// Serial.println(" A ");
// Serial.print("moyenne ");
// Serial.println(somme / mesure);
// turn the ledPin on
// digitalWrite(ledPin, HIGH);
// // stop the program for <sensorValue> milliseconds:
// delay(sensorValue);
// // turn the ledPin off:
// digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
// delay(1);
}