Need help for a new project program

The project it self is done, but I don't now what is wrong with the program.

#include <Servo.h>

int Main;
int motorB;
int motorP;

Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;
Servo motor5;

int alt;

int buto1;
int buto2;
int buto3;
int buto4;
int buto5;

int pote1 = 0;
int pote2 = 0;
int pote3 = 0;
int pote4 = 0;
int pote5 = 0;

void setup() {
pinMode(7, INPUT);


pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);

void loop() {
goto Main;
alt = digitalRead(7);
if (alt = HIGH) {
goto motorB;
if (alt = LOW) {
goto motorP;
goto Main;

buto1 = digitalRead(8);
if (buto1 == LOW) {
else {

   buto2 = digitalRead(9);  
   if (buto2 == LOW) {
   else {

   buto3 = digitalRead(10);  
   if (buto3 == LOW) {
   else {

   buto4 = digitalRead(11);  
   if (buto4 == LOW) {
   else {

   buto5 = digitalRead(12);  
   if (buto5 == LOW) {
   else {

if (alt = HIGH) {
goto motorB;
else {
goto Main;

pote1 = analogRead(A1);
int pos1 = map(pote1, 0, 1023, 0 , 180);

   pote2 = analogRead(A2);
   int pos2 = map(pote2, 0, 1023, 0 , 180);

   pote3 = analogRead(A3);
   int pos3 = map(pote3, 0, 1023, 0 , 180);

   pote4 = analogRead(A4);
   int pos4 = map(pote4, 0, 1023, 0 , 180);

   pote5 = analogRead(A5);
   int pos5 = map(pote5, 0, 1023, 0 , 180);

if (alt = LOW) {
goto motorP;
else {
goto Main;

I haven't had a good look, but lines like that should be == not =.

And all those gotos are going to make it very difficult to debug for someone like me who hasn't used goto since Fortran 45 years ago, sorry.

This is the first thing that is wrong. Goto is not the way to go.
With a little help you could switch this over to a properly structured program.

You can create pretty much any program using:

  • Iterative logic, those are your for loops and while loops to do something over and over but only in one place, like turning on a sequence of lights
  • Branching logic, those are your if/else and switch to decide which path your program takes
  • Functional logic, those are subroutines, functions that you create to do the same thing in different parts of your program without repeating code

I bet you a glazed donut that if we get your code goto free you'll understand it better and your problem will either be fixed or be easier to spot and fix.

Are you up for the challenge?

Describe your project in simple words and this very simple.

It's in the wrong forum section, and missing code tags.

You could ask a moderator to fix the first for you.

Then there's the gotos and the comparisons.

Probably some of the variables don't need global scope.

Named pins would help.

A simple bionic hand.

Sorry, it's my first time using this forum. I don't really know how to use C++.

Which functions have the used buttons and pots and what is the functional relation between both?
Sorry, my crystal ball is in the dishwasher.

both moves the same engines, in analog or digital form, depending on switch position.

In this case design a common data structure, so called object containing all related information pro "finger" and use a function/methode to work on this data structure. Shortly called: Use the C++ programming languages to design a proper and smart sketch.
Have a nice day and enjoy coding in C++.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.