Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Arduino LiPo Checker
- *
- * learnelectronics
- * 30 JUN 2017
- *
- * www.youtube.com/c/learnelectronics
- *
- *
- *
- * NOTE: My 18650 gave these readings, yours may differ. If it does simply change the values in the if statements:
- *
- * 4.2V 975
- * 3.7V 882
- * 2.7V 650
- */
- #define red 6
- #define yellow 4
- #define green 3
- #define lipo A0
- float lipoV = 0;
- void setup() {
- pinMode(red,OUTPUT);
- pinMode(yellow,OUTPUT);
- pinMode(green,OUTPUT);
- pinMode(lipo,INPUT);
- Serial.begin(9600);
- }
- void loop() {
- lipoV = analogRead(lipo);
- Serial.println(lipoV);
- if(lipoV<650){
- digitalWrite(red,HIGH);
- digitalWrite(yellow,LOW);
- digitalWrite(green,LOW);
- }
- if(lipoV>800 && lipoV<950){
- digitalWrite(red,LOW);
- digitalWrite(yellow,HIGH);
- digitalWrite(green,LOW);
- }
- if(lipoV>950){
- digitalWrite(red,LOW);
- digitalWrite(yellow,LOW);
- digitalWrite(green,HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement