Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LoBrol committed Oct 30, 2022
1 parent 195dd67 commit 2aa0ca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions LinoRoboArm.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ void LinoRoboArm::setServos(uint16_t newPositions[6]) {


/**
* @brief Parse input from string to specified servo position.
* @brief Parse input from string to specified servo position, and (if correct) save to curPos array.
* @param command command string
* @return True if input valid, False if invalid.
*/
bool LinoRoboArm::parseInput() {
bool LinoRoboArm::parseInput(String command) {
bool inputValid = false;
uint8_t servo = inputString.charAt(0) - 48;
uint8_t servo = command.charAt(0).toInt();
if(servo >= 0 && servo <= 6) {
inputValid = true;
uint16_t newPos = inputString.substring(1,4).toInt();
uint16_t newPos = command.substring(1,4).toInt();
curPos[servo] = checkPos(servo, newPos);
}
return inputValid;
Expand Down
6 changes: 5 additions & 1 deletion LinoRoboArm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@





/* ================================================================================================================================= */


Expand All @@ -23,6 +25,8 @@ bool stringComplete = false;





void serialEvent() {
while(Serial.available()) {
char inChar = (char)Serial.read();
Expand All @@ -48,7 +52,7 @@ void loop() {
if(stringComplete) {
Serial.print("Comando: ");
Serial.println(inputString);
arm.parseInput();
arm.parseInput(inputString);
arm.setServos();
Serial.print("Posizioni correnti: ");
arm.printPositions();
Expand Down

0 comments on commit 2aa0ca4

Please sign in to comment.