Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float currentSense = 0.0;
- int currentPin = 0;
- int voltagePin = 1;
- void setup(){
- Serial.begin(9600); //Begin Serial @ 9600bps
- Serial.println("Serial Connection Established"); //Notify that the Serial Connection has been established
- analogReference(DEFAULT); //Use the 5v External Analog Reference Voltage
- pinMode(3, OUTPUT);
- }
- void loop()
- {
- float voltage;
- do{
- digitalWrite(3, HIGH);
- float voltage = (analogRead(voltagePin)/1023.0)*5;
- float currentSense = ((analogRead(currentPin)/1023.0)*5.0)/0.9771;//2.0681; //Divide Current sense reading by 1024 to get voltage
- Serial.print((float)currentSense); //Print currentSense to the Serial Port
- Serial.print(", "); //Comma for separtion of data
- Serial.print((float)voltage);
- Serial.print(", ");
- Serial.println(float((currentSense * voltage)));
- delay(1000); //Wait 500ms so as not to flood with data
- }while(voltage > 2.8);
- }
Add Comment
Please, Sign In to add comment