From 832ea4bb91d4bd0bc36895f29e2f4a9e949ac8ce Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 1 Aug 2023 23:38:12 +0200 Subject: [PATCH] Initial commit. Learning stuff --- README.md | 3 +++ main.ino/main.ino.ino | 42 ++++++++++++++++++++++++++++++++++++++++++ main.py | 22 ++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 README.md create mode 100644 main.ino/main.ino.ino create mode 100755 main.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff0ea95 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# arduino-fridge-powercontrol + +A small project to turn my 12V cooling boxes aka mini-fridge on or off depending on their temperature inside. diff --git a/main.ino/main.ino.ino b/main.ino/main.ino.ino new file mode 100644 index 0000000..38cf0c3 --- /dev/null +++ b/main.ino/main.ino.ino @@ -0,0 +1,42 @@ + +int analogPin = 3; +int data = 0; +char userInput; + +void setup() { + // put your setup code here, to run once: + pinMode(LED_BUILTIN, OUTPUT); + Serial.begin(9600); + +} + +void loop() { + // put your main code here, to run repeatedly: + if(Serial.available()>0) { + + userInput = Serial.read(); + + if(userInput == 'g') { + + data = analogRead(analogPin); +/* + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(200); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(200); + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(200); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(200); + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(200); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(200); + + */ + delay(2000); + Serial.println(data); + } + } + +} diff --git a/main.py b/main.py new file mode 100755 index 0000000..63b5e88 --- /dev/null +++ b/main.py @@ -0,0 +1,22 @@ +#!/bin/python3 + +import serial +import time + +ser = serial.Serial('/dev/ttyACM0', baudrate = 9600, timeout = 1) + +time.sleep(3) + +def getValues(): + #ser.write(b'g') + lol = "g" + ser.write(str(lol).encode('ascii')) + arduinoData = ser.readline().decode('ascii') + return arduinoData + +while 1: + userInput = input('Get data point?') + + if userInput == 'y': + print(getValues()) +