Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double values[15];
- boolean firstRun=true;
- double tip=0;
- double realVoltage=0;
- int j=0;
- void setup(){
- Serial.begin(9600);
- Serial.println("Serial Started w00t");
- }
- void loop(){
- tip=analogRead(0);
- if(tip>150){
- // Serial.print("Incoming Voltage is ");
- // Serial.println(analogRead(0));
- if(firstRun){
- for(int i=0;i<15;i++){
- values[i]=tip;
- }
- firstRun=false;
- }
- values[j]=tip;
- tip=0;
- for(int i=0;i<15;i++){
- tip+=values[i];
- }
- tip/=15;
- realVoltage = ((((tip*(5.0/1023.0))*7000)/5000)*50);
- //Serial.print("Real voltage: ");
- Serial.println(realVoltage);
- j++;
- if(j>=15){
- j=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement