author2
2Instructables220,850Views114CommentsUKJoined March 7th, 2016

Tell us about yourself!

Complete Your Profile

Achievements

100+ Comments Earned a bronze medal
10K+ Views Earned a bronze medal
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 4 months ago
    Easy Arduino Menus for Rotary Encoders

    Hi, the section of the Instructible that talks about codes portability is the hint that it won't work on many microcontrollers. I have not tried to port the code to the ESP32 but you may find some inspiration in JulekT's code that only needs one interrupt pin. Find an alternative way to digitally read the relevant pins simultaneously or in very quick succession and you will be on your way.

    Do you want help with the rotary encoder part of the project? What specific challenge to do with rotary encoders would you like help with?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading6 months ago
    Improved Arduino Rotary Encoder Reading

    Yes, that detail was hidden in the text: "Note: In the diagram the ground pin is one of the end pins. In reality, the ground pin is often the centre pin but this is not always the case so read the datasheet or test your encoder to find out which pin is ground."

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 7 months ago
    Easy Arduino Menus for Rotary Encoders

    Sorry for the late reply. I haven't implemented this myself and don't plan to. I hope you found a way round.

    Good approach if you need the other hardware interrupt (eg if you want to use two encoders on an ATMEGA328PB)

    Sorry for the late reply. If you look in the code for the button press (non-delay type) you could start storing the millis() in variables. You can then compare when the button was pressed with the time it was released and then decide if you want to enter or exit or increment a mode.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 10 months ago
    Easy Arduino Menus for Rotary Encoders

    Try the same modeMax approach in other modes as is used in Mode 0: if (encoderPos > (modeMax+10)) encoderPos = modeMax; // check we haven't gone out of bounds below 0 and correct if we have else if (encoderPos > modeMax) encoderPos = 0; // check we haven't gone out of bounds above modeMax and correct if we haveThis should limit the values that encoderPos can adopt. You will need to create different variable names for your limit (such as modeMax0, modeMax1 etc.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 11 months ago
    Easy Arduino Menus for Rotary Encoders

    Thanks for letting me know this Instructable was useful to you - I owe much to people taking time to share knowledge online so it's good to know I'm giving back in a small way. I'm sure people would be interested in the teensy ported version, as well as some of your other features.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    Glad to hear you worked it out! Thanks for letting us know your experience - I'm sure it'll help others.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    Hi, that does sound like a voltage / pin connection issue from what you have mentioned. I would try other combinations of pin connections, perhaps with a physical indication of the pin voltage like a resistor and LED from the pin to ground in parallel with the signal lines.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    I would look in rotaryMenu() and in the conditional statement if(oldEncPos != encoderPos) { // DEBUGGINGI would put further checks for which direction, such as:if(oldEncPos > encoderPos) keyboard.press "a";else keyboard.press "b";}then I would look in the "if buttonState == LOW" as you already have done to put the keyboard.press "c". Not sure why it's currently triggering when you press the button unless you are rotating the encoder as you press it.

    In //Main menu section if (Mode == 0) {...try changing:if (buttonPressed){ Mode = encoderPos; // to:if (buttonPressed && encoderPos == 0) { // this will only let the button change the mode if the encoder is at zero Mode = (Mode+1) % 2 ; // this will alternate the mode between 0 and 1. Just increase 2to 3 to get three modes etc.Otherwise you'll need to post your code before people can help much more.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    If it's a message you don't want to put in the comments, I think you can send me a private message using your Instructables account.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    Hi BlueM7, sorry I didn't get a notification for your comment. I haven't used this yet but I have bought something like this for my new jog controller https://m.banggood.com/100PPR-6-Terminal-Eletronic-Hand-Wheel-Manual-Pulse-Encoder-Generator-For-CNC-Machine-p-1121930.html?You may also like my approach to a jog controller https://hackaday.io/project/29627-grbl-man-in-the-middle-cnc-jog-pendant

    View Instructable »
  • SimonM83 commented on focamonca's instructable Refusbish Your SOLDERING IRON TIP1 year ago
    Refusbish Your SOLDERING IRON TIP

    This kind of advice often brings out valuable advice in the comments. Thanks to people who chip in but I'm not sure I'm much further ahead in terms of knowing how to look after my TS100 tips!

    View Instructable »
  • SimonM83 commented on WillLorien's instructable How to Make a Rockoon: Project HAAS1 year ago
    How to Make a Rockoon: Project HAAS

    This is a great Instructable! So much for others to learn about what it is really like to try something you haven't done before. Thank you for sharing.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    Hi MarcoM280, I would declare a further variable "encoderPosButton". Then, instead of:"if (reading == B00001100 && bFlag) { //check that we have both pins at detent (HIGH) and that we are expecting detent on this pin's rising edge encoderPos ++; //increment the encoder's position count"Use:"if (reading == B00001100 && aFlag) { //check that we have both pins at detent (HIGH) and that we are expecting detent on this pin's rising edge if (buttonPressed) encoderPosButton --; //decrement the encoder's button closed position count else encoderPos --; //decrement the encoder's button open position count"Then, you need to do the same changes to the encoderPos increment section:"if (reading == B00001100 && bFlag) { //check that ...

    see more »

    Hi MarcoM280, I would declare a further variable "encoderPosButton". Then, instead of:"if (reading == B00001100 && bFlag) { //check that we have both pins at detent (HIGH) and that we are expecting detent on this pin's rising edge encoderPos ++; //increment the encoder's position count"Use:"if (reading == B00001100 && aFlag) { //check that we have both pins at detent (HIGH) and that we are expecting detent on this pin's rising edge if (buttonPressed) encoderPosButton --; //decrement the encoder's button closed position count else encoderPos --; //decrement the encoder's button open position count"Then, you need to do the same changes to the encoderPos increment section:"if (reading == B00001100 && bFlag) { //check that we have both pins at detent (HIGH) and that we are expecting detent on this pin's rising edge if (buttonPressed) encoderPosButton ++; //increment the encoder's button closed position count else encoderPos ++; //increment the encoder's button open position count"You can get rid of most of the menu code as this only relies on the encoder reading BUT you need to keep the buttonPressed code! Good luck - I haven't tested this but it should help you get round your mental block!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    Thanks 400 Hz! Good to keep people up to date. I'm going to leave the code in the Instructable the same for now but will consider changing it if people have issues.

    Bullfrogerwytsch, glad you got it sorted and although I don't have an immediate application for your menu I'm sure it would be helpful for others. Please post in the comments! Thanks.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    Not specifically. You'd have to convert encoder position to an angle (perhaps use map() function), then compare the angle value to your limit/threshold (perhaps use if() function). Then you can do what you want to inside the if() function. You can do all that inside your loop () function.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    Thanks Christian!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    TylerM173, can you explain what you're trying to achieve with a bit more detail and context? Are you talking about a 360 degree rotation of the encoder or just one detent? Or half to a quarter of a detent (as there are two zero phases and they overlap)?The code already adds/subtracts 1 to/from encoderPos if you rotate through the contacts for one detent. If you're talking about a full 360 rotation, you can just set an if() statement which resets the variable encoderPos to zero when it goes above the same number of detents per rotation.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    Hi Pierre, thanks for taking the time to let people know how you are using the code. Ideas of the possible applications are always useful, especially when someone can confirm it's feasible. The code in the my Instructables uses some language elements that are specific to the ATMEGA328P (which is why you need different code for the MEGA2561). You might be able to spot how to adapt the external interrupts to work with the Wemos D1 mini from this blog post https://techtutorialsx.com/2016/12/11/esp8266-external-interrupts/Please come back and tell us how you get on.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    kd6oji, I'm not sure how to put this into a library. Can't you just use the clickbutton library from https://github.com/pkourany/clickButton/tree/master/src and keep the encoder code in the main sketch?

    View Instructable »
  • SimonM83 made the instructable Vacuum Pump From Aquarium Air Pump1 year ago
    Vacuum Pump From Aquarium Air Pump

    Random_Canadian thank you for this Instructable! I want to make a vacuum pickup tool for an OpenPNP machine and tried to copy this Instructable exactly. I couldn't buy a "Whisper 100" model but did buy the Tetra APS 100 (designed for 50-100 litre tanks). It has a single diaphragm and outlet so it may turn out to be undersized for other people looking to buy a similar pump for an SMT part pickup application.I found the (single) white plastic part quite difficult to slide out before I could rotate it and reverse the valves to create a vacuum. I was worried that I'd break something if I forced the white plastic up and out of its slot because the design didn't exactly match the photos in this Instructable. However, I can confirm that a right angle hex key levered it out intact, wi...

    see more »

    Random_Canadian thank you for this Instructable! I want to make a vacuum pickup tool for an OpenPNP machine and tried to copy this Instructable exactly. I couldn't buy a "Whisper 100" model but did buy the Tetra APS 100 (designed for 50-100 litre tanks). It has a single diaphragm and outlet so it may turn out to be undersized for other people looking to buy a similar pump for an SMT part pickup application.I found the (single) white plastic part quite difficult to slide out before I could rotate it and reverse the valves to create a vacuum. I was worried that I'd break something if I forced the white plastic up and out of its slot because the design didn't exactly match the photos in this Instructable. However, I can confirm that a right angle hex key levered it out intact, without any damage, from under the bottom face of the white plastic square flange.I then rotated the square and replaced it. When I turned it on I felt the vacuum and it seems like it could hold small SMT parts but that will need testing. When I put my finger over the outlet, the diaphragm inside got pulled in by the vacuum and this caused the magnetic pump head to hit the plastic inside the casing. It was now a very noisy vacuum pump! See the yellow circle and arrow in the attached photo to see where the impact occurs.I have heard this noise when watching YouTube videos of DIY pick and place machines, and now I know where it comes from. As I now understood the problem, I wanted to reduce the noise, as it would clearly be the most noisy part of an OpenPNP DIY machine and I didn't want to be annoyed during its operation.To solve the problem, I added a spring from a ballpoint pen between the housing and the pump arm and held it in place with hot glue. See the light blue outline in the attached photo to see the arrangement I used. The pump is now quieter when I put my finger over the outlet (now the inlet, I suppose!) than when it is free running against no pressure. I'm very happy and hope these extra details help others get what they want from these great little devices.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading1 year ago
    Improved Arduino Rotary Encoder Reading

    kd6oji, that's encouraging to hear and thanks for taking the time to let us know!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 1 year ago
    Easy Arduino Menus for Rotary Encoders

    Hi coffs, sorry I didn't reply earlier. I haven't tried this but I believe it is possible to set up sub menus by placing one in each setting. It would lead to significantly more case/switch code unless you can modularise it.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    My electronics knowledge isn't great but you might be able to reduce the workload for the processor using an op amp as a comparator and/or (!) some logic gates. Perhaps some latching would be required. I'm not working on anything like this but if you find something, please post a link!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Bryan, from what you've said I believe the Uno is absolutely capable of meeting your needs. Just use a Pin Change Interrupt (as per the Nick Gammon guide I linked to in my other reply) for the Z reset. You can use a display with an I2C or SPI interface if you want or set up a software serial pair of Rx/Tx pins to talk to another device (but I would like to think your further calculations can be done on the first Uno). Depending on your display interface, that will steer you to what pins remain for your Pin Change Interrupt. Keep at it. Even if you decide to order a Mega 2560, try the pin change interrupt on the Uno while you're waiting. You can even get a neopixel ring of colour changing leds and use those to display the angle of the encoder readout. That would only require one digital ...

    see more »

    Bryan, from what you've said I believe the Uno is absolutely capable of meeting your needs. Just use a Pin Change Interrupt (as per the Nick Gammon guide I linked to in my other reply) for the Z reset. You can use a display with an I2C or SPI interface if you want or set up a software serial pair of Rx/Tx pins to talk to another device (but I would like to think your further calculations can be done on the first Uno). Depending on your display interface, that will steer you to what pins remain for your Pin Change Interrupt. Keep at it. Even if you decide to order a Mega 2560, try the pin change interrupt on the Uno while you're waiting. You can even get a neopixel ring of colour changing leds and use those to display the angle of the encoder readout. That would only require one digital pin as well as power and ground. There's loads of guidance on neopixel and arduino on the Internet. Keep going!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Hi Bryan, thanks for posting in the comments. Before we get to your main issue, I want to say you've done a good job changing encoderPos to a larger size than a Byte but you might also want to change oldEncoderPos in the same way. So, the problem is that you are trying to put a hardware interrupt on a pin which doesn't support it (digital pin 4). Only pins 2 and 3 support the kind of interrupt code we've used here. However, you can add pin change interrupts to the other pins (beware that it involves a whole port and therefore up to 8 pins - suggest you may want to look at using the analog pins if you want to reserve pin 13 as your LED pin. The best guide I know to all kinds of interrupts is by Nick Gammon (who is attributed in my code) and his section on pin change interrupts is here - ...

    see more »

    Hi Bryan, thanks for posting in the comments. Before we get to your main issue, I want to say you've done a good job changing encoderPos to a larger size than a Byte but you might also want to change oldEncoderPos in the same way. So, the problem is that you are trying to put a hardware interrupt on a pin which doesn't support it (digital pin 4). Only pins 2 and 3 support the kind of interrupt code we've used here. However, you can add pin change interrupts to the other pins (beware that it involves a whole port and therefore up to 8 pins - suggest you may want to look at using the analog pins if you want to reserve pin 13 as your LED pin. The best guide I know to all kinds of interrupts is by Nick Gammon (who is attributed in my code) and his section on pin change interrupts is here - good luck: http://gammon.com.au/forum/?id=11488&reply=6#reply6

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Glad it made sense - looking back it wasn't the clearest explanation!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    "B" means a binary number (Google if you want further explanation). The list of 1s and 0s after is a list of bits that make up a Byte. Each bit represents a pin on the microcontroller. The pins are grouped into "ports" which each have 8 pins, so a single binary Byte can represent the digital state of a whole port. To use code that commands the ports (called port manipulation), you have to find which port pins 20 and 21 etc are on. Eg they are on Port D. 21 is PD0, 20 is PD1 (goes in reverse). So in the byte which describes the whole of PortD, they are B000000(20)(21). Google for a "atmega 2560 pinout diagram" to check the pin assignment to ports if you don't want to look at the datasheet (which I do recommend). Then change the code which relates to port man...

    see more »

    "B" means a binary number (Google if you want further explanation). The list of 1s and 0s after is a list of bits that make up a Byte. Each bit represents a pin on the microcontroller. The pins are grouped into "ports" which each have 8 pins, so a single binary Byte can represent the digital state of a whole port. To use code that commands the ports (called port manipulation), you have to find which port pins 20 and 21 etc are on. Eg they are on Port D. 21 is PD0, 20 is PD1 (goes in reverse). So in the byte which describes the whole of PortD, they are B000000(20)(21). Google for a "atmega 2560 pinout diagram" to check the pin assignment to ports if you don't want to look at the datasheet (which I do recommend). Then change the code which relates to port manipulation (B000XXXX, PIN(Y), PORT(Z) etc).

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Hi Nurochim, this has been asked and answered partly in the comments below and the comments for my menu instructable. If you're a newbie and you want to make this work, you have a little bit of learning to do but that's great if you're doing this for a school project.Here's the text from some relevant comments. You might need the datasheet for the ATMEGA2560 and/or a port manipulation guide and pinouts for the ATMEGA2560:"Hi, I haven't tested this but I expect the reason it doesn't work directly with the mega2560 is because the interrupt service routine relies on port manipulation and the mega2560's hardware interrupt pins aren't on the same ports as the atmega328. My code above could be easily adapted for the mega2560 if you change PIND to the correct port, eg PINE, to read port E...

    see more »

    Hi Nurochim, this has been asked and answered partly in the comments below and the comments for my menu instructable. If you're a newbie and you want to make this work, you have a little bit of learning to do but that's great if you're doing this for a school project.Here's the text from some relevant comments. You might need the datasheet for the ATMEGA2560 and/or a port manipulation guide and pinouts for the ATMEGA2560:"Hi, I haven't tested this but I expect the reason it doesn't work directly with the mega2560 is because the interrupt service routine relies on port manipulation and the mega2560's hardware interrupt pins aren't on the same ports as the atmega328. My code above could be easily adapted for the mega2560 if you change PIND to the correct port, eg PINE, to read port E. It looks like arduino interrupt pins are on 2 and 3, which appears to equate to PE4 and PE5. That means you also need to change the B0000XX00 to bit shifting/ masking/ comparing B00XX0000 (PE0 will be the right hand bit, PE7 will be the left hand bit) to deal with the readings from your encoder. Good luck with the edit - I think it's definitely doable. Please post the code you change once you get it working so other people can use this on the mega2560""Suppeschluerfer SimonM83Reply9 months agoMega 2560 - Pin 2(INT0) and 3(INT1):PIND & 0xC change to PINE & 0x30B00001100 change to B00110000B00000100 change to B00010000B00001000 change to B00100000"

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Hi alfabcd6, if you look at the code you can see modeMax and this sets the maximum value of the main menu. It sounds like you want to set the maximum value of your submenus. If so, you can add in modeMax1, modeMax2, modeMax3 etc. Then, in each case also include the modeMax code, as in: if(encoderPos > modeMax1+10){encoderPos = modeMax1};and:if(encoderPos > modeMax1) {encoderPos = 0};and then do that for each submenu. I hope that helps - let me know.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    nathan2484, well done for coming up with a solution! Just for interest and in case you hadn't understood the cause of the number rolling over, if you look at the code, we declared the variable "encoderPos" as a byte. This just rolls over to 0 (or, in binary, 00000000) when you add 1 to 11111111 (ie 255) because if it were to be a 9 bit (as opposed to 8 bit) number it would tick over to 256 = 100000000. The 8 bit (1 byte) variable just ignores the 9th bit, reading from right to left, so we get back to 0. I hope I have explained that clearly enough. Using an "if" statement is a good way to control the upper and lower values of your encoderPos variable. Thanks for your kind gratitude.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Ralphxyz, I'm scratching my head on this one, as it's a directional issue that is at the encoder rather than the Arduino. Is there a chance that you have connected the wrong wire to Ground? Can you try different combinations of wiring?

    Amazing! I was just trying to think what to try next when I saw that you solved it. Well done!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Ralphxyz, does this stay the same if you swap your wires around?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    SiDawg, glad to hear it's helped you and thanks for contributing to the community by posting your own findings.

    RonVZ, I'm sorry I missed your comment. The code is specific to the two inputs as-written but I see no reason why you can't add a second encoder. You will need to add the extra interrupts and write the Interrupt Service Routine to read and process the Port reading relevant to the new encoder input pins. You should be able to get a clue about the microcontroller's handling of the bit-math by looking at the comments in the existing ISR code. Good luck and I hope this is still helpful.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Sorry, I got confused when I commented that other people had addressed the 2560 in these comments - actually it was in the comments on my rotary encoder menu instructable. Check out this awesome Instructable. https://www.instructables.com/id/Easy-Arduino-Menus-for-Rotary-EncodersIf you scroll down to the comment by Suppeschluerfer there are suggestions for port (code) and pin settings on the 2560. I haven't tested it yet so it would be great if you could confirm if it worked.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Hi Ron, here are the sections of code which refer to the push button/switch that represents a "select" input from the user:const byte buttonPin = 4; // this is the Arduino pin we are connecting the push button tovoid rotaryMenu() { ......// Button reading with non-delay() debounce - thank you Nick Gammon! byte buttonState = digitalRead (buttonPin);... (then the following logic in the rest of the rotaryMenu function)If you want to use the lcd, you need to put some code in that displays what you want, when you want. The code I've suggested isn't for an lcd, it uses the computer screen to display text in the Arduino IDE's serial monitor window when the Arduino is connected to the computer. If you look at the comments from TheMariuzaz below and my responses to them, you should se...

    see more »

    Hi Ron, here are the sections of code which refer to the push button/switch that represents a "select" input from the user:const byte buttonPin = 4; // this is the Arduino pin we are connecting the push button tovoid rotaryMenu() { ......// Button reading with non-delay() debounce - thank you Nick Gammon! byte buttonState = digitalRead (buttonPin);... (then the following logic in the rest of the rotaryMenu function)If you want to use the lcd, you need to put some code in that displays what you want, when you want. The code I've suggested isn't for an lcd, it uses the computer screen to display text in the Arduino IDE's serial monitor window when the Arduino is connected to the computer. If you look at the comments from TheMariuzaz below and my responses to them, you should see what I mean by some code to make the lcd display something. The adafruit tutorial for your lcd should give you the correct kind of code to use.

    Ron, it sounds like you're trying to bite off a pretty challenging project for the level of skill you appear to have in this area. Even switching from LCD to OLED between your two comments would mean different technologies that have different driver chips and need different code to communicate with them.Let's try getting the OLED working. I don't use Mac, so some bits may be specific to the OS. What adafruit product do you have? Can you post a link? Have you searched for other people having and solving issues with connecting to it? Someone might have a much better ready-made answer already on the arduino or other forum than I could come up with. If you've managed to download the relevant libraries and install them correctly in the arduino IDE, I assume you've opened an example sketch fo...

    see more »

    Ron, it sounds like you're trying to bite off a pretty challenging project for the level of skill you appear to have in this area. Even switching from LCD to OLED between your two comments would mean different technologies that have different driver chips and need different code to communicate with them.Let's try getting the OLED working. I don't use Mac, so some bits may be specific to the OS. What adafruit product do you have? Can you post a link? Have you searched for other people having and solving issues with connecting to it? Someone might have a much better ready-made answer already on the arduino or other forum than I could come up with. If you've managed to download the relevant libraries and install them correctly in the arduino IDE, I assume you've opened an example sketch for the display. Do you have the correct Arduino board selected in the IDE when you compile? It's a long shot but perhaps worth checking. Which Arduino are you using? You'll need to post much more information before people can help you get further with this. I'd recommend setting up an Arduino forum thread on this issue if you can't find a similar one that has already been started.

    Ron, it's a good sign that you have the other sketches working (I presume other than blink, which comes preloaded?).When you went and installed the SSD1306 and GFX libraries, did you follow these instructions from adafruit:Rename the uncompressed folder Adafruit_SSD1306 and check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.hPlace the Adafruit_SSD1306 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.We also have a great tutorial on Arduino library installation at:http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-useBecause that's pretty fundamental during compilation. Do you know if you have a libraries folder in the place where ...

    see more »

    Ron, it's a good sign that you have the other sketches working (I presume other than blink, which comes preloaded?).When you went and installed the SSD1306 and GFX libraries, did you follow these instructions from adafruit:Rename the uncompressed folder Adafruit_SSD1306 and check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.hPlace the Adafruit_SSD1306 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.We also have a great tutorial on Arduino library installation at:http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-useBecause that's pretty fundamental during compilation. Do you know if you have a libraries folder in the place where you usually save sketches (try Save As on the blink sketch and see if you can see a libraries folder when it opens up the default location. If not, follow the libraries advice in the adafruit link.Good move including the screenshot. In Arduino IDE can you go to File/Preferences and tick the box for verbose output during compile? Then try and compile again (which should spit out lots more detailed text at the bottom of the screen) and press the button to the right of the orange error message bar which says "Copy error messages" and then Google that text to see if you have a common problem, paste it here and use it in any Arduino forum thread you write on.

    Ron, I've just tried compiling this in both versions of the Arduino IDE that I have. I have Windows but I noticed that I got the same error as you did when you used version 1.8 when I used version 1.6.9. I tried it with the much older version 1.0.5. and it compiled. Can you get hold of version 1.0.5 for Mac? Worth a shot.

    View Instructable »
  • FerretPi: Using Raspberry Pi as a Secure FTP Server

    Is any of the data on the USB stick encrypted at rest by VSFTPD? Ie if I remove the USB drive can I easily read what it contains? Tried looking for an answer elsewhere but search results focused on the security of data in transit, not on the hard drive. Thanks, Simon

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    TheMariuzaz I'm glad it worked - I'm not sure I helped at all but it's great that you worked things through!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    I'm struggling to see where your code fits into mine from the pastebin link. if (setting1 > 0) { lcd.setCursor(0,1); lcd.write(" "); lcd.setCursor(11,1); lcd.write((uint8_t)0); } Should it be:if (setting1 > 0) { lcd.setCursor(0,1); lcd.write(" "); lcd.setCursor(11,1); lcd.write((uint8_t)setting1); } ? It seems like both conditions of setting1 =0 OR setting1 > 0 lead to the lcd displaying 0.

    Are you saying you still have the same problem? I don't know if this is an issue but:if(setting1 <0){is confusing me. Are you supposed to check if a value is LESS than zero in your program?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Have you tried putting an lcd update term in place of every Serial.println() and Serial.print()?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Thanks for the simplifications. This is where a github repository would come in handy! Anyone with an account care to commit this code? Sorry to hear about your encoders. I think the ones I tested with were no-name eBay specials so that's surprising. No joy if you change the debounce time?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Glad to hear it's useful. The button reading part is all Nick Gammon's - he's got a great website full of useful information, especially about atmega328p arduinos.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    That's a shame - I thought my encoder I used to test the system was a cheap one even though it was advertised as something better.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Githyuk, thanks so much for the update - that's the kind of thing that will really help someone else who may be losing patience. I have edited the Instructable in Step 2 and signposted them to the details in your comments. So glad it's working well for you now!

    Sorry, what I meant by branded was that it was a known part and therefore results should be repeatable (versus an unbranded eBay special). You're right to isolate the issue to the detent per pulse (although I'm not clear if it's 2 pulses per detent on the kind of encoder which works or 2 detents per pulse). Please show us the final results of your project.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    I think there are three ways I'd try initially. First, for periodic updates you could use a non-blocking timer such as the method used in "blink without delay" sketches and the button press debouncing code I used in this (Nick Gammon's). Just put the if(millis() - delay > lastTime) type of statement in the main loop. Second, you can just add your "read temp, display temp" code in each of the if (Mode == X) statements for VERY frequent updates. Thirdly, if you can wait for temp to update only when you press the select button, place your "read temp, display temp" code in the setAdmin function. My preference would be the first option. Let us know how you get on.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Hmm, I used an Alps EC11B0924802 but I think the logic is all the same apart from whether the pins are grounded or not at detent. You might want to look at whether your reset is around B00001100 or B00000000. Other than that, I wonder if the capacitor is preventing the pin from reaching a 0 in sufficient time but I can't think what situation this could realistically occur in. Try without caps perhaps? Does it work in the same direction if you swap the arduino pins over?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Hi Githyuk, sorry it's not working yet. Can you confirm that this behaviour is the same at low rotation speed? This would help rule out contact bounce. You could add some hardware debouncing to be sure. From not knowing much about your setup (although encoder datasheet link was a good idea), I think there might be a situation where the other pin is always high when the other one triggers the interrupt. E.g, if you read B00001000, then you can get B00001100 but never B00000100 or B00000000. If this is the case, it could be a short circuit on the wiring to the pin, pulling it HIGH, or it could perhaps be that one of the Arduino pins is connected to the encoder ground pin. The data sheet didn't seem to be clear about which pins are A, B and ground (although it would be a good first assumpt...

    see more »

    Hi Githyuk, sorry it's not working yet. Can you confirm that this behaviour is the same at low rotation speed? This would help rule out contact bounce. You could add some hardware debouncing to be sure. From not knowing much about your setup (although encoder datasheet link was a good idea), I think there might be a situation where the other pin is always high when the other one triggers the interrupt. E.g, if you read B00001000, then you can get B00001100 but never B00000100 or B00000000. If this is the case, it could be a short circuit on the wiring to the pin, pulling it HIGH, or it could perhaps be that one of the Arduino pins is connected to the encoder ground pin. The data sheet didn't seem to be clear about which pins are A, B and ground (although it would be a good first assumption that a = A, b =B and c = ground. Perhaps check the wiring for pull-up short circuits and the try different combinations of encoder wiring. Hope that helps - post pictures if you have no joy.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Awesome! Congratulations and thank you for sharing - you've designed an nice screen layout there.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Charles, I'm so glad to hear you are making headway. The other Instructable you mentioned isn't mine but that's the beauty of the community.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    Cool, glad you think it will be helpful - please post a picture of the screen when you get it working.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Hi Charles, are you thinking of using the menu I describe in my other Instructable? I'm not sure what LCD library you plan to use but in the sketch you can try placing something along the lines of (depending on the code you use to get the lcd to display characters):lcd.write("Mode selected: "); instead of the Serial.print() equivalent andlcd.writeln("Configure stepper"); instead of the Serial.println(Mode); line to show what setting you are affecting in the menu. Hope that helps.

    In this section... if(oldEncPos != encoderPos) { // DEBUGGING Serial.println(encoderPos);// DEBUGGING. Sometimes the serial monitor may show a value just outside modeMax due to this function. The menu shouldn't be affected. oldEncPos = encoderPos;// DEBUGGING }// DEBUGGINGReplace:Serial.println(encoderPos);with something like a series of if statements like... if(encoderPos = 0) lcd.write("Configure Camera") ;else if(encoderPos = 1) lcd.write("Set IN Point") ;else if(encoderPos = 2) lcd.write("Set OUT Point") ;else if(encoderPos = 3) lcd.write("Configure Stepper") ;Let us know how you get on.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    I'm not familiar with any setups like that but it doesn't look like there's a pin conflict. Haven't had a look into whether there are interrupt conflicts but that'd be a good place to start if you run into issues. Go for it (and let us know how it goes)!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Easy Arduino Menus for Rotary Encoders 2 years ago
    Easy Arduino Menus for Rotary Encoders

    You're welcome, great to hear it's appreciated!

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Thank you for taking the time to share your findings with us all - especially the confirmation that you did not need hardware debouncing.

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    If you look back at the decisions I made, one of the trade-offs was to use port manipulation to achieve speed. This unfortunately means that you would need to rewrite the code to make it work on boards that don't use the ATMEGA328P chip. Some people have done this for the ATMEGA2560 in these comments but that was the same "8 bit AVR" style as the ATMEGA328P so didn't require massive code changes. The Due is a "32 bit ARM" style of microcontroller and you'd need to look carefully into whether it can do something that is akin to port manipulation. The good news is that the Arduino community has probably worked this out already so you are only a few searches away from finding out how feasible editing the code is in this way. The other bonus of the Due is that it process...

    see more »

    If you look back at the decisions I made, one of the trade-offs was to use port manipulation to achieve speed. This unfortunately means that you would need to rewrite the code to make it work on boards that don't use the ATMEGA328P chip. Some people have done this for the ATMEGA2560 in these comments but that was the same "8 bit AVR" style as the ATMEGA328P so didn't require massive code changes. The Due is a "32 bit ARM" style of microcontroller and you'd need to look carefully into whether it can do something that is akin to port manipulation. The good news is that the Arduino community has probably worked this out already so you are only a few searches away from finding out how feasible editing the code is in this way. The other bonus of the Due is that it processes information much faster than the ATMEGA328P so you can probably just read each encoder pin in sequence without needing port manipulation in the first place. You'd have to work out how to compare the readings to determine whether you have passed a detent and in which direction but that's exactly what had to research when I decided to make this code. cli and sei are AVR instructions to turn interrupts off and on. I'm sure you can find a way of doing this with your Due. For example, the arduino functions nointerrupts() and interrupts() will probably do the trick and may have been a better way to write my own code but I wasn't sure if these functions would result in a larger sketch or slower execution when compiled so I went for the AVR commands to play it safe. Good luck and if you make a Due version of the code, please publish it for the benefit of others!

    View Instructable »
  • SimonM83 commented on Grissini's instructable Dead Edge End Table2 years ago
    Dead Edge End Table

    This is a great instructable - magazine-worthy writing that takes us right to where you are, a lovely insight into the design thinking and plenty of helpful tips. Thank you

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    Which board and IDE you using?

    View Instructable »
  • SimonM83 commented on SimonM83's instructable Improved Arduino Rotary Encoder Reading2 years ago
    Improved Arduino Rotary Encoder Reading

    [Usual disclaimer about responsibility for your own purchasing decisions] Yes, looks like it will be compatible with the Arduino and the code! I like the sound of your project - would you mind putting a link or photo in the comments when you're done? 180° sounds like a good match with servos - probably cheaper and simpler than stepper motors, depending on the torque required. Your 25 turn coil would probably need steppers or a motor with feedback (another rotary encoder!).Good luck!

    View Instructable »
  • More Activities