From 00e72663be02ae5c5648ac583dcb620d202efa3f Mon Sep 17 00:00:00 2001 From: RABijl Date: Tue, 19 Apr 2022 22:07:02 +0000 Subject: [PATCH 1/3] adds a tool to move servo --- tools/control_servo_with_serial.cpp | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tools/control_servo_with_serial.cpp diff --git a/tools/control_servo_with_serial.cpp b/tools/control_servo_with_serial.cpp new file mode 100644 index 0000000..58166ee --- /dev/null +++ b/tools/control_servo_with_serial.cpp @@ -0,0 +1,64 @@ +#include "Arduino.h" +#include + +#ifdef U8X8_HAVE_HW_SPI +#include +#endif +#ifdef U8X8_HAVE_HW_I2C +#include +#endif + +Servo serv; +int pos = 0; +int newPos = 0; + +bool handleInp = false; + +void setup() +{ + // initialize LED digital pin as an output. + pinMode(LED_BUILTIN, OUTPUT); + serv.attach(PIN5); + Serial.begin(9600); +} + +void loop() +{ + + if (handleInp == true) { + digitalWrite(LED_BUILTIN, HIGH); + if(newPos != pos){ + serv.write(newPos); + pos = newPos; + delay(300); + } + handleInp = false; + delay(300); + digitalWrite(LED_BUILTIN, LOW); + + } + + +} + +String line = ""; +void serialEvent() +{ + + while(Serial.available()) + { + + char ch = Serial.read(); + if(ch == '\n' ){ + Serial.println("received this: " +line); + newPos = line.toInt(); + handleInp = true; + line=""; + + }else if(ch != 13){ + line += ch; + } + + } +} + From abda4302d3f92310dface4299f8d90fd72b6ff29 Mon Sep 17 00:00:00 2001 From: RABijl Date: Tue, 19 Apr 2022 22:12:19 +0000 Subject: [PATCH 2/3] updates vscode extension --- .vscode/extensions.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0f0d740..080e70d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} From 19c4777cff7336f8824eeaef8048f7e7f74ae7c0 Mon Sep 17 00:00:00 2001 From: RABijl Date: Tue, 19 Apr 2022 22:28:51 +0000 Subject: [PATCH 3/3] updates project file to use new bootloader --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 83d2f5a..36bace2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,9 +8,9 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:nanoatmega328] +[env:nanoatmega328new] platform = atmelavr -board = nanoatmega328 +board = nanoatmega328new framework = arduino debug_tool = simavr lib_deps =