je veut convertir un code d'ARDUINO en un code STM
je veut savoir comment on peut réaliser ca
si il y a un site qui explique la conversion ? svp d'aide
============================== =
Code sourceCode:#include <LiquidCrystal.h> const int sensorIn = A0; int mVperAmp = 185; // 5A version SC712 – use 100 for 20A Module or 66 for 30A Module int Watt = 0; double Voltage = 0; double VRMS = 0; double AmpsRMS = 0; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { pinMode(6, OUTPUT); Serial.begin (9600); Serial.println (“Hall sensor”); lcd.begin (20, 4); // set up the LCD – number of columns, rows lcd.clear (); lcd.setCursor (0, 0); lcd.print (“Hall sensor”); digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) } void loop() { Serial.println (“”); Voltage = getVPP(); VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707 – dealing with sine AmpsRMS = (VRMS * 1000)/mVperAmp; Serial.print(AmpsRMS); Serial.print(” Amps RMS — “); Watt = (AmpsRMS*240/1.3); // note: 1.3 is my own empirically established calibration factor // as the voltage measured at A0 depends on the lenght of the OUT-to-A0 wire // 240 is the mean AC grid power voltage – this parameter fluctuates locally Serial.print(Watt); Serial.println(” W”); lcd_control (); } // ***************** subroutines **************************** float getVPP() { float result; int readValue; // value read from the sensor int maxValue = 0; // store max value here int minValue = 1024; // store min value here uint32_t start_time = millis(); while((millis()-start_time) < 1000) //sample for 1 Sec { readValue = analogRead(sensorIn); // see if you have a new maxValue if (readValue > maxValue) { /*record the maximum sensor value*/ maxValue = readValue; } if (readValue < minValue) { /*record the minimum sensor value*/ minValue = readValue; } } // Subtract min from max result = ((maxValue – minValue) * 5.0)/1024.0; return result; } void lcd_control (){ lcd.setCursor (5, 2); lcd.print (Watt); lcd.print (” watt “); }
-----