Guest User

Untitled

a guest
Jan 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. float currentSense = 0.0;
  2. int currentPin = 0;
  3. int voltagePin = 1;
  4.  
  5. void setup(){
  6. Serial.begin(9600); //Begin Serial @ 9600bps
  7. Serial.println("Serial Connection Established"); //Notify that the Serial Connection has been established
  8. analogReference(DEFAULT); //Use the 5v External Analog Reference Voltage
  9. pinMode(3, OUTPUT);
  10.  
  11. }
  12.  
  13. void loop()
  14. {
  15. float voltage;
  16. do{
  17. digitalWrite(3, HIGH);
  18. float voltage = (analogRead(voltagePin)/1023.0)*5;
  19. float currentSense = ((analogRead(currentPin)/1023.0)*5.0)/0.9771;//2.0681; //Divide Current sense reading by 1024 to get voltage
  20. Serial.print((float)currentSense); //Print currentSense to the Serial Port
  21. Serial.print(", "); //Comma for separtion of data
  22. Serial.print((float)voltage);
  23. Serial.print(", ");
  24. Serial.println(float((currentSense * voltage)));
  25. delay(1000); //Wait 500ms so as not to flood with data
  26. }while(voltage > 2.8);
  27. }
Add Comment
Please, Sign In to add comment