Have you ever wanted to know the exact number of turns you put into your coil ?
With this fast little trick, you will be able to count the number of turns that you put into your coil.
What you need :
- 1x : Arduino Uno/Nano
- 1x : Reed Switch (opened by default)
- 1x : neodynium magnet
- 1x : Push Button
- 1x : 16×2 LCD Screen (I2C)
Schematic :
The Setup :
And for sure the Arduino Code :
#include <Wire.h> #include <LiquidCrystal_I2C.h> //PIN MODES const int pinButtonReset = 9; //pin for the reset command button const int pinReedSwitch = 2; //pin for the reed switch //DISPLAY CONSTANTS const int START = 0; // Basic Menu first menu to display int menu = 0; //Setting to START menu when powering on the device int menuType = START; //INIT COUNTER int count = 0; long lastDebounce = 0; long debounceDelay = 20; // Ignore bounces under 20ms LiquidCrystal_I2C lcd(0x3F,16,2); //crystal adress for real LCD //LiquidCrystal_I2C lcd(0x27,16,2); //crystal adress for the LCD in Proteus void setup() { lcd.init(); //init for LCD lcd.backlight(); //light for LCD Serial.begin(9600); //serial feedback pinMode(pinButtonReset, INPUT_PULLUP); pinMode(pinReedSwitch, INPUT); digitalWrite(pinReedSwitch, HIGH); attachInterrupt(digitalPinToInterrupt(2), counter, FALLING); updateDisplay(); //display menu } void loop() { stateButtonReset(); //we check the status of the reset button updateDisplay(); //display data delay(500); } void updateDisplay() { lcd.clear(); //clear display before printing switch (menuType) { case START: lcd.setCursor(0,0); //top left lcd.print("Turns:"); //we print the text on the screen lcd.print(count); break; } } void counter() { //we increase the counter if( (millis() - lastDebounce) > debounceDelay){ count++; lastDebounce = millis(); } } void stateButtonReset() { //we check the button if (digitalRead(pinButtonReset)==LOW) count = 0; }