tag:blogger.com,1999:blog-5911939370761516849.post3715686542231005928..comments2024-02-16T00:23:08.019-08:00Comments on Digitalduino: R2R Button Resistor LadderJordanhttp://www.blogger.com/profile/03951190922958142729noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5911939370761516849.post-62019806233604081342013-08-09T09:31:26.817-07:002013-08-09T09:31:26.817-07:00fuck yea hahafuck yea hahaJordanhttps://www.blogger.com/profile/03951190922958142729noreply@blogger.comtag:blogger.com,1999:blog-5911939370761516849.post-49325069215710603482013-08-09T08:12:13.528-07:002013-08-09T08:12:13.528-07:00As an admitted noob, you just solved my design qua...As an admitted noob, you just solved my design quandary. Kudos to you.Brenthttps://www.blogger.com/profile/10412532581405062870noreply@blogger.comtag:blogger.com,1999:blog-5911939370761516849.post-89752535798704087132013-05-02T06:47:54.372-07:002013-05-02T06:47:54.372-07:00run the sketch and hold down the button you want t...run the sketch and hold down the button you want to find the value of now it should be printing to the serial terminal in the arduino IDE. but the value wont always be the exact same thing. it may be off a number or two, so take the value and think of a range so if the serial termianl says 505, your min would be 500, the max would be 510.<br /><br />if(AnalogBtn >= 500 && AnalogBtn <= 510)<br /> {<br /> Button1Cnt +=1;<br /> Serial.print("Button 1 pressed "); Serial.print(Button1Cnt); Serial.println(" times.");<br /> }Jordanhttps://www.blogger.com/profile/03951190922958142729noreply@blogger.comtag:blogger.com,1999:blog-5911939370761516849.post-76737643802913501322013-05-02T01:56:28.252-07:002013-05-02T01:56:28.252-07:00how do u calculate the analog values? i mean the &...how do u calculate the analog values? i mean the "(AnalogBtn >= 508 && AnalogBtn <= 510)" for example, how do u get that number?ballenhttps://www.blogger.com/profile/03525337975089507109noreply@blogger.comtag:blogger.com,1999:blog-5911939370761516849.post-3430752204487834992013-03-04T10:19:52.033-08:002013-03-04T10:19:52.033-08:00yeah, thats a good idea. basically something like ...yeah, thats a good idea. basically something like this:<br /><br />for(int i =0; i<5; i++)<br />{<br />AnalogBtn = 0;<br />AnalogBtn += analogRead(AnalogBtnPin);<br />}<br /><br />AnalogBtn = AnalogBtn/5<br /><br />for anyone who wants it<br />Jordanhttps://www.blogger.com/profile/03951190922958142729noreply@blogger.comtag:blogger.com,1999:blog-5911939370761516849.post-3305417782349587012013-03-04T04:03:57.239-08:002013-03-04T04:03:57.239-08:00Nice :)
You can also enhance the readings accurac...Nice :)<br /><br />You can also enhance the readings accuracy using some software debouncing + "value sampling".<br /><br />ie : when pressing button (if enough time has elapsed after button is clicked), read the input for X times, and add each reading to an accumulator.<br />Then, to get the final read value, divide the accumulator value by X. That way, you get an average value that will even any difference from successive readings.<br /><br />For X, you can use any value, but powers of 2 are better (say 16, 32,64, etc) 'cause the compiler can optimize it with a shift instruction (which is faster).Unknownhttps://www.blogger.com/profile/04327483756861362199noreply@blogger.com