Notifications
Clear all

I fell in love with the LED & KEY board

120 Posts
7 Users
19 Likes
38.4 K Views
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Mine came pretty quick too.  I live in Pennsylvania USA.  I'm pretty sure they came by air mail.   They came too fast to have been shipped on a boat.   I haven't tested them all yet.  They all look good though.   Feels good to have a drawer full of them now.   I already have plans for at least four of them and I'm sure I'll be finding uses for the rest. 

I've been thinking about making a homemade DRO for my lathe.   I haven't decided on what to use for the position sensor yet.  I'd like to have both the main carriage and the cross slide sensed for position to hopefully within 0.001 inch.   Obviously 0.0001 would be even better.  Although my lathe is lucky to cut to 0.001" as it is.  But it's nice to be able to see on the display a better resolution than I actually need.

Still open on what to use as a position sensor though.   Not sure whether I should go with some sort of mechanical sensor like a potentiometer of some sort, or whether I should try a light laser distance sensor?

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@robo-pi

James, I have gone down a slightly different road.

1. I have initiated all the booleans as "true", to get rid of that awful ternary function.

2. I have added display test routine into the setup() function.

3. I have started referencing the 7 segment display hex values from an array.

 

Your opinion is of course greatly valued!


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @pugwash

1. I have initiated all the booleans as "true", to get rid of that awful ternary function.

I forgot the ternary function was still in there.  I changed it to buttons_n = !buttons_n before but must have accidentally reverted back to a previous version without realizing it.   By the way, you can still initiate all the booleans as false and work in positive logic.  Just place the buttons_n = !buttons_n before the if statements instead of after them.   Technically it doesn't matter.  It will work either way.   It's your choice whether you want to work in positive or reverse logic.  I prefer to work in positive logic in case I want to test whether a button is currently on or not at some other point in the program.   The way you have it set up true would be off and false would be on.   So that could be confusing later in the program if you want to test whether a button is currently activated.  That's why I chose to have all the booleans be false at the onset.   No buttons have yet been pressed.

By the way, the "awefulness" of the ternary function is a matter of personal taste.  I kind of like it.  But I agree that button_n = !button_n is a easier to read, especially for beginners who may not even be aware of the ternary function or how it works.   I confess that I just learned about the ternary function because it was used in this program.  So I was using it to get a feel for how it works.  I can see where it can come in handy in other situations.  So there may actually be situations where its use can be quite elegant.   But I agree, it's overkill in this particular situation.   And button_n = !button_n is much more readable and straight forward.  But  you don't need to use negative logic.   You can still initiate the buttons as false if you want to work in positive logic.

Like I say, I was thinking ahead in case I want to use those booleans later to check whether a particular button is active or not.   The way you have it now True = button inactive, and False = button active.   That's reversed logic.   It's still usable, but you'll need to constantly remember that it's reverse logic if you want to use those booleans in other parts of your program later to check to see whether a particular button function is active or not.

Posted by: @pugwash

2. I have added display test routine into the setup() function.

Yes that makes it nice and automatic. ?   You'll still need to go through all the buttons too though if you want to test them as well.   There's no way to test the buttons automatically.   You need to actually press them to see if they are working.   I'm surprised at how well these buttons physically work.   All the boards I ordered have excellent buttons that have really good action.   I haven't had a problem with a button on any of them.

Posted by: @pugwash

3. I have started referencing the 7 segment display hex values from an array.

Yes, this is the best way to go.  I should have done that on day one.   This way everything is defined within the program.  It would probably be nice to have a method that adds the decimal point to whatever numeral you send to it.  That would make it easy to add the decimal point to a numeral without having to have a whole second table of numeral with decimal points.  I think all you need to do is OR them with 0x80 as the msb is the decimal point.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

By the way, you can still initiate all the booleans as false and work in positive logic.  Just place the buttons_n = !buttons_n before the if statements instead of after them.

I don't follow your reasoning!

Buttons are initiated as true!

If (button_1)  // is button_1 true?

   //function

button_1 = !button_1  // change to false until a physical button is pressed

I don't see that as negative logic!


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@robo-pi

James, would you take a look at this?

I have added a another small function demo1() but it is doing some strange things!

for some reason, it is falsely displaying 0 2 4 6 8 from the left, but it is then incrementing each segment from 0 - 9 sequentially starting on the rightmost segment, as it should.

Can't for the life of me see why!


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @pugwash

@robo-pi

James, would you take a look at this?

I have added a another small function demo1() but it is doing some strange things!

for some reason, it is falsely displaying 0 2 4 6 8 from the left, but it is then incrementing each segment from 0 - 9 sequentially starting on the rightmost segment, as it should.

Can't for the life of me see why!

Trying adding the following command to your setRegister() method.

sendCommand(0x44)

 

void setRegister(byte addr, byte value){
      sendCommand(0x44); // <---- Try adding this line here.
      digitalWrite(strb, LOW);
      shiftOut(data, clk, LSBFIRST, addr); // Address of 8th digit
      shiftOut(data, clk, LSBFIRST, value); // Numeral 8
      digitalWrite(strb, HIGH);
}

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@robo-pi

Didn't need a nap!

void demo1(){
for(int i = 7;i > -1; i--){ //TO MANY ARRAY ITEMS WAS THE PROBLEM
for (int j = 0; j < 10; j++){
setRegister(segmentReg[i], hexChar[j]);
delay(250);
}
}
}

Staring me in the face as usual!


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

@pugwash

I just ran  your new demo sketch.   Pretty cool. ? 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 
Posted by: @robo-pi

I have a couple projects I'm working on that I needed to have both highly visable display output and a few function buttons.  I was going to design my own board and then I ran across these:

 

Boy are these nice!  They have 8 LEDs across the top.  And eight 7-segement displays.   And across the bottom they have 8 push button switches.

I bought two of these to experiment with @ $1.80 a piece.  I just got done programming one (or I should say that I programmed an Arduino UNO to send and receive data from one of these boards) and I can tell you they are extremely easy to use.  And very readable.   I got so excited I just ordered 10 more of them for $13.50 with free shipping.    That's only $1.35 a piece.  You'd be hard-pressed to try to build anything similar using only $1.35 worth of parts.   So these are super fantastic to have in my parts drawer.   I'm sure I'll be using these everywhere and probably end up wanting to order even more. ? 

Could you post a link to where you bought these little gems?

Thank you...

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @joelyddon

Could you post a link to where you bought these little gems?

10 pcs Key Display TM1638 module - AliExpress

I guess I better order some more before they're all sold out. ? 

DroneBot Workshop Robotics Engineer
James


   
JoeLyddon reacted
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 
Posted by: @robo-pi

@pugwash

I just ran  your new demo sketch.   Pretty cool. ? 

Thanks!

I am currently working on displaying decimals!

I have decided to keep all the current values for the registers in a temporary array. Change the values in the temporary array when necessary and then update all the registers in one go, if any value changed.

I'll be back when I have made some more progress.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @pugwash

I'll be back when I have made some more progress.

Keep up the good work!  I'm sure others will appreciate your contributions as well.  The more code we post the easier it will be for others to understand how to use the features of this board.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Page 3 / 8