Mini Bowling Alley ...
 
Notifications
Clear all

Mini Bowling Alley Pin Setter coding project In need of tutoring...

169 Posts
7 Users
4 Likes
41.1 K Views
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@zeferby

wow... great info... lots to digest!  Please let me say I am learning a lot and figuring out a lot at the same time!  this is awesome, fun, and rewarding!

Feeling a little better about my project knowing I an not a "complete fool"


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 

@dundervetter

Lol, not a fool at all !

By the way, the debouncing example you mentionned some time ago also uses the same "elapsed time measurement" technique.

Eric


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  
 
Posted by: @dundervetter

void sweeperUp() {  // move sweeper to the up position  pwm.writeMicroseconds(sweeperVerticalMotorPin, 1474); }

so is this method essentially creating variables or constants... the word void just throws me off...

This post was modified 4 years ago by Dundervetter

   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1038
 
Posted by: @dundervetter

So what was frustrating originally was the PCA9685... because the PCA9685 is the actually "object" so you have to address each pin by their actual PIN number to get the servos to work independently of each other.

I think one response above had suggested using some 'define' statements to handle the pin numbers of the PCA9685 for each servo, but you could also equate your values for the travel limits of each servo to some variable name.  Such as:

// Using a more descriptive name for the servos
define sweeperlift 0
// Obviously other servos have to be defined as well
// just using one for this example
// Now the assignment of position values
int SweeperUp=1474;
int SweeperDown=1978;
// Then somewhere further down in your code
pwm.writeMicroseconds(sweeperlift,SweeperUp);
// or to lower the sweeeper it would be just 'SweeperDown'
// instead of 'SweeperUP'

These are somewhat longer variable names, but it makes it easier to understand the code and almost makes it self documenting.

SteveG


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@codecage

ok that makes sense... and as you said essentially the readability... 

not sure if should go making those changes now but for now this will be really useful for the future!!!


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1038
 
Posted by: @dundervetter

the word void just throws me off..

The void is there because no values are being returned from the function being defined.

Sometimes when you define a function you might expect some value to be returned to you when the function is called and then you would declare the type of variable being returned.  Here we expect no return value, so we use the type 'void.'

If you were defining a function to find the square root of a number it might start off like this:

float squareroot(number){
//rest of the code goes here;
}

Here we have used 'float' type instead of 'void' type.  Hope that helps

SteveG


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1038
 
Posted by: @dundervetter

not sure if should go making those changes now but for now this will be really useful for the future!!!

No I wouldn't go making those changes now, but something for the future,

SteveG


   
Dundervetter reacted
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@codecage

ok so yes that does make more sense now!  Always learning thank you!


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@pugwash

I did not find the drone bot workshop video just yet but found one from How to Mechatronics.  So not saying I will install just yet... just learning and thinking... for my application you are thinking to use it as a distance/proximity measurement rather the counting/ assessing rotation?


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1038
 

The most exciting thing about this forum is how it brings us all together from different parts of the world, from different cultures, each with our own experiences, but with a common goal, and that is to learn.

I don't think I have you @dundervetter, is it Jason, placed on the globe yet, but @robo-pi, James, is in the US in Pennsylvania, is that right James?  @pugwash, SteveC, is in Germany. @zerferby, Eric, is in France. Our leader @dronebot-workshop, Bill, is in Canada,  And I'm in the US in Georgia.

This forum has folks from all over the world!

SteveG


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@codecage

I too am from PA... outside of Reading... which isn't too far from philly either

Posted by: @codecage

but @robo-pi, James, is in the US in Pennsylvania, is that right James? 


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  
Posted by: @codecage

The most exciting thing about this forum is how it brings us all together from different parts of the world, from different cultures, each with our own experiences, but with a common goal, and that is to learn.

This is awesome!


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 
Posted by: @dundervetter

concept od the state machine

If you want to have a look at other finite state machine examples, this guy has a rather good series presenting one here (and  accompanying YT videos as well)

Eric


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 
Posted by: @codecage

This forum has folks from all over the world!

Conspiracy, taking the world over ! ? 

Eric


   
ReplyQuote
Page 4 / 12