Notifications
Clear all

[Solved] I can't find the info I need

63 Posts
6 Users
22 Likes
3,953 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@davee I wired the 10k in as suggested, but my multimeter still show 3.3V when the switch is closed. I removed the PULLUP from the sketch and reversed the Led. NOTHING changes the behaviour and most changes result in worse behaviour.

Given the documentation comment about the inverted on-board LED I am wondering if this is normal behaviour for this board.

Tomorrow I will try an ESP32 board and see what happens.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@will So I am putting 3.3V on a pin that already has 3.3V. No surprise that doesn't change anything. I put my meter between 3.3V G and the pin and press the button and see 3.3V before and after. This doesn't make any sense.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2537
 
Posted by: @zander

@will So I am putting 3.3V on a pin that already has 3.3V. No surprise that doesn't change anything. I put my meter between 3.3V G and the pin and press the button and see 3.3V before and after. This doesn't make any sense.

I agree, it doesn't make any sense at all.

I'll try wiring this up on an Arduino tomorrow as a rough sanity check because this is very weird !

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@will Time for my old friend Sherlock. If I remove the wire from the input pin the LED lights, that means the readDigital SAW HIGH and my meter agrees. If I then ground that pin, the LED's swap. It would appear this is it's normal operation. I will change the sketch to deal with it.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2537
 

@zander 

WOW, that's going to trip up a lot of people who want to use both devices !

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi @zander and @will,

 The circuit I found and referenced earlier includes:

image

this shows that the Blue LED is connected to 3.3V and hence the GPIO pin must be taken low to switch it on.

Oddly it shows the onboard LED connected to GPIO16 .. which it shows is also connected to pin15 on the board .. and comparing with the board picture, maybe D0 ... none of which seem to match the program you listed!! Maybe there is a mismatch between the schematic and your board?

------------------------------------------

I also have my doubts that your wiring in the photo matches your diagram ... I have a feeling the LED goes to gnd and the switch to 5V ... but it is difficult to be sure.

-------------------------------------

On the plus side,

As you say ....

When wired as I showed earlier the board blue led comes on, then when I press the button the board blue led goes out and the red led turns on.

I think your program maybe working ..., although I have no idea why the onboard LED goes out when you press the button ... unless it is wired to the same GPIO pin as your Red LED ... which doesn't match the schematic ... which is quite possible.

Also, I think the program is suggesting that pressing the button takes it high ... which contradicts your sketch.

You also say.

When I add a 10k resistor between the pin and ground, the board blue led comes on and the red led comes on at 1/2 intensity. Pressing the button does nothing.

That is not what I suggested to do ... the 10k resistor should go to 3.3V, not ground ... but it doesn't sound right. If you have a multimeter I think it would be a good idea to measure the voltages as I described earlier. You may find the input pin is somewhere in the middle ... say 1.5V

-----------

I think you are nearer but maybe not completely there yet ... but that is the way progress happens.

Make sure the only 5V connection is to the Vin pin on the board ... then battle on .. perhaps tomorrow after a break!! I feel a bit more comfortable that your board appears to be 'still alive'.

Good luck, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@davee The mystery of the onboard LED is solved, I was using D4 which is the onboard LED. I now changed to D5 but no change in behaviour. I don't have the energy anymore (I am 80 in a week and have been at this for 12ish hours) so I am calling it quits for now. I will read your last response tomorrow, thanks for being invooved.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@davee The onboard LED mystery is resolved, I was using the wrong pin.

I am going to start over with a published wiring diagram and code. Looking at it I already see a problem as I can not understand how the push button works. Here is the link to the sample https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

I can see in the tab labelled schematic how pin 2 is tied to ground thru the 10k resistor and to 5V when the switch is closed. 

HOWEVER, I can not see how that happens in tab layout. I guess I do not understand how a switch works internally. In the layout the pins at top right and bottom right must be connected and must stay connected to agree with the schematic. To put 5V onto pin 2 the shorting bar must go from lower left to upper right. That is new to me, I metered my switch to verify what I thought would happen and wired it accordingly.

When I metered it before I guessed at how it might work and only metered to confirm my guess. This time I will wire it according to the diagram and see what the meter tells me. 

Do not fret over voltages. I am using one of those little supplies that plug into the breadboard and one rail is plugged for 3.3 while the other is plugged for 5. The ONLY thing plugged into the 5V is the board's 5Vpin and G, every other wire is in the other rail.

One thing I noticed in the example I will now use is it tells me how to change the behaviour by wiring it either pullup or pulldown. I would really appreciate your help showing me how the diagram changes to accomplish that but only after I get the first version to work.

I will still use an ESP8266 even though the sample is an UNO, it's just one digital pin in and one out.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@zander 

Where did you get your circuit example and code?

https://osoyoo.com/2017/05/09/nodemcu-lesson-4-button-control-led/

 


   
Ron reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

Hi @zander,

If you are defining a button switch with a pinMode parameter of input, then you should incorporate a pull down resistor in the circuit, say 10k ohm.  In this mode the switch is read as on when it goes high. In this mode one side of switch should be wired to +5v.

Otherwise, use input_pullup in the pinMode call. In this mode the switch is read as on when it goes low. In this mode one side of switch should wired to gnd.

 

Depending on which style of wiring you use be sure to ensure the digitalRead function checks the right state for what defines 'on'.

Hope this sorts the issue?

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Ron reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1721
 

Hi Ron @zander,

Sounds like you are making real progress .. well done! It is difficult to explain, but whenever I try something new, everything seems to really difficult and even the simplest of things seems to be impossible.. but as I get more familiar, the 'fog' gradually lifts.

As for the switch, the switches that I bought that look like the Arduino picture have 4 'legs', but only two distinct contacts. Essentially two legs on each side are the same piece of metal, so as you have already discovered, the Arduino diagram is using one pair to connect pin 2 on the board to the left hand end of the resistor. Of course, this means you have to be careful which way round you plug the (almost) square switch into the board ... accidentally rotating it by 90 degrees will completely change the circuit. So it is always wise to check the switch out before connecting it up.

I also found it necessary to straighten the 'kinks' in the legs before pushing into the breadboard, to make sure they were long enough to make a secure contact... they are designed for soldering into a PCB which needs shorter leads.

I am relieved you have only put 3.3V onto the components (excepting Vin). Of course the 3.3V from your regulator should be fine  ... alternately you can use one of the 3.3V pins on the ESP8266 board, providing the demand will only be a few milliamps or less.

Hopefully you now understand what is meant by 'pullup' and 'pulldown'. The Arduino circuit you referenced obviously uses a resistor to pull pin 3 Down to ground, and the switch to pull it high.

Personally I would have preferred the resistor and the switch were swapped, so that the resistor pulls high when the switch is open, and the switch pulls it down when closed. Although this is somewhat counterintuitive in that the pressed switch results in '0', it used to be 'mandatory' practice to only pull an input high using a resistor, because of fears any voltage transients on the line could damage the chip. I know some designers ignore this rule now, but I still prefer it!

Once you have got the basic circuit working, you might like to try swapping th eswitch and the resistor as an extension exercise in getting familiar with the concepts, noting that you can make a small change in your program to compensate if you want the relationship between pressing the switch and the LED lighting to stay the same.

Swapping between '0' to make something happen and '1' to make it happen is extemely common in real circuits...there is a "law" somewhere that states that which ever one you expected, it will usually turn out to be the other one and will need a fix! 😀 

Hope this is all clear. Best wishes, Dave

 


   
Ron and ron bentley reacted
ReplyQuote
ron bentley
(@ronbentley1)
Member
Joined: 2 years ago
Posts: 385
 

@davee 

Go for the two pin button switches, they fit a breadboard perfectly and are snug, unlike the hideous four pin varieties which I cannot ever get to fit without popping out and breaking contact!!

 

Ron Bentley
Creativity is an input to innovation and change is the output from innovation. Braden Kelley
A computer is a machine for constructing mappings from input to output. Michael Kirby
Through great input you get great output. RZA
Gauss is great but Euler rocks!!


   
Ron and DaveE reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@robotbuilder Not sure, in any case I am starting from scratch as soon as I can figure out how to find a suitable pin and what it's called in software. At the moment it appears I have a 3.3V pin as input and that's not right.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@ronbentley1 I think I have tried all that. Starting over.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7099
Topic starter  

@davee Thank you for that very good explainer. I have just pulled apart the breadboard as I a convinced it is haunted. After a blessing I will start over with a new simpler sketch

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

I think you are right, I very likely had the switch in wrong. That was error #1, error #2 was using the internal LED pin as the input, # 3 error was not knowing about the pull up/down R's.

This is why I am starting over with a simple circuit. YES, I agree 100% to start small and as the fog clears build up. I am sending you a private message as well. Thanks.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
DaveE reacted
ReplyQuote
Page 3 / 5