Initial commit. Learning stuff

This commit is contained in:
Marcus 2023-08-01 23:38:12 +02:00
commit 832ea4bb91
3 changed files with 67 additions and 0 deletions

3
README.md Normal file
View file

@ -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.

42
main.ino/main.ino.ino Normal file
View file

@ -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);
}
}
}

22
main.py Executable file
View file

@ -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())