Advertisement
Tywais

Milliohm Meter

Feb 3rd, 2024 (edited)
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <MCP3304.h>
  2. #include <SPI.h>
  3.  
  4. MCP3304 adc1(10); //creat an instance with pin 10 as CS
  5.  
  6. int reading;
  7. float voltage;
  8. float resistance;
  9. const float current = .125;
  10. const float reference = 2.048;
  11.  
  12. void setup(){
  13. Serial.begin(38400);
  14. }
  15.  
  16. void loop(){
  17.  
  18. reading = adc1.readAdc(0,1); //read data from CH0 in SGL mode
  19. voltage = reading / 4095.0 * reference;
  20. Serial.print(voltage,6);
  21. Serial.println(" Volts");
  22.  
  23. resistance = voltage/current;
  24. Serial.print(resistance,6);
  25. Serial.println(" Ohms ");
  26. Serial.println(" ");
  27.  
  28. delay(1000); //delay for 1s so you dont get to much lines in the serial monitor
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement