Guest User

Untitled

a guest
Jul 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
  4.  
  5. const int currentPin = A0;
  6. int sensitivity = 66;
  7. int adcValue= 0;
  8. int offsetVoltage = 2500;
  9. double adcVoltage = 0;
  10. double currentValue = 0;
  11.  
  12. void setup()
  13. {
  14. Serial.begin(9600);
  15. lcd.begin(16, 2);
  16. lcd.print(" Current Sensor ");
  17. lcd.setCursor(0,1);
  18. lcd.print(" with Arduino ");
  19. delay(2000);
  20. }
  21.  
  22. void loop()
  23. {
  24. adcValue = analogRead(currentPin);
  25. adcVoltage = (adcValue / 1024.0) * 5000;
  26. currentValue = ((adcVoltage - offsetVoltage) / sensitivity);
  27.  
  28. Serial.print("Raw Sensor Value = " );
  29. Serial.print(adcValue);
  30.  
  31. lcd.clear();
  32. delay(1000);
  33. //lcd.display();
  34. lcd.setCursor(0,0);
  35. lcd.print("ADC Value = ");
  36. lcd.setCursor(12,0);
  37. lcd.print(adcValue);
  38.  
  39. delay(2000);
  40.  
  41. Serial.print("\t Voltage(mV) = ");
  42. Serial.print(adcVoltage,3);
  43.  
  44. lcd.setCursor(0,0);
  45. lcd.print("V in mV = ");
  46. lcd.setCursor(10,0);
  47. lcd.print(adcVoltage,1);
  48.  
  49. delay(2000);
  50.  
  51. Serial.print("\t Current = ");
  52. Serial.println(currentValue,3);
  53.  
  54. lcd.setCursor(0,0);
  55. lcd.print("Current = ");
  56. lcd.setCursor(10,0);
  57. lcd.print(currentValue,2);
  58. lcd.setCursor(14,0);
  59. lcd.print("A");
  60. delay(2500);
  61. }
Add Comment
Please, Sign In to add comment