Notifications
Clear all

Encoder with Servo Tutorial Error Code with sketch

8 Posts
3 Users
1 Likes
691 Views
(@tckellogg)
Active Member
Joined: 1 year ago
Posts: 10
Topic starter  

I am trying to use an encoder to run a servo with an Arduino uno card. I have loaded the sketch shown on the video from your tutorial and I get the error shown in the pictures below. I've checked it three times and every time I get the same error. Anyone know what I am doing wrong

IMG 3705
IMG 3704

 


   
Quote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 4801
 

Please use a screen grab, photos of screens is not usable. Also go into the IDE preferences and crank the compiler warnings to ALL.

BTW, how many years coding experience do you have, hobby or job?

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 4801
 

If you are new, here are some screen shots showing how to do what I asked.

Screen Shot 2022 06 05 at 10.45.05
Screen Shot 2022 06 05 at 10.45.30

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
(@tckellogg)
Active Member
Joined: 1 year ago
Posts: 10
Topic starter  

@zander Unfortunately my programming experience is less than a week. I've mostly been taking courses and doing a few basic sketches. I made the changes you requested and here is the screen grab you requested.

2022 06 05

 


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 4801
 

@tckellogg missing { after loop()

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Will
 Will
(@will)
Famed Member
Joined: 2 years ago
Posts: 2326
 

@tckellogg 

Your problem (this time) is that you are not using the brace brackets to properly contain the code associated with the subroutines.

In particular, this error derives from your code which is effectively ...

void loop() .... code body ...

whereas the code body for the loop sub must be placed inside brace brackets as ...

void loop() {.... code body ...}

In this case the compiler sees a bunch of code ranging around loose and so it cannot compile it properly.

 

You have created the setup code correctly, use the same form for loop and you'll be past this problem 

 

Experience is what you get when you don't get what you want.


   
Ron reacted
ReplyQuote
(@tckellogg)
Active Member
Joined: 1 year ago
Posts: 10
Topic starter  

@will Thanks for the help. That fixed it. I can't take credit for the sketch. I was just copying and pasting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 4801
 

@tckellogg You are welcome. Here is a hint, use select all (cmd-a apple or ctrl-a win) on the original sketch so the copy paste doesn't miss any parts.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote