Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <MCP3304.h>
- #include <SPI.h>
- MCP3304 adc1(10); //creat an instance with pin 10 as CS
- int reading;
- float voltage;
- float resistance;
- const float current = .125;
- const float reference = 2.048;
- void setup(){
- Serial.begin(38400);
- }
- void loop(){
- reading = adc1.readAdc(0,1); //read data from CH0 in SGL mode
- voltage = reading / 4095.0 * reference;
- Serial.print(voltage,6);
- Serial.println(" Volts");
- resistance = voltage/current;
- Serial.print(resistance,6);
- Serial.println(" Ohms ");
- Serial.println(" ");
- delay(1000); //delay for 1s so you dont get to much lines in the serial monitor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement