{"generator":"Jekyll","link":[{"@attributes":{"href":"https:\/\/justpushbuttons.com\/feed.xml","rel":"self","type":"application\/atom+xml"}},{"@attributes":{"href":"https:\/\/justpushbuttons.com\/","rel":"alternate","type":"text\/html"}}],"updated":"2018-09-28T16:26:19+00:00","id":"https:\/\/justpushbuttons.com\/","title":"just push buttons","subtitle":"my website","entry":[{"title":"Enabling File Extensions In Finder","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2018-09-14\/enabling-file-extensions-in-finder","rel":"alternate","type":"text\/html","title":"Enabling File Extensions In Finder"}},"published":"2018-09-14T00:00:00+00:00","updated":"2018-09-14T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2018-09-14\/enabling-file-extensions-in-finder","content":"<p>I like to see the file extensions in Finder. I had to look up how to do this. Here\u2019s how you do it:<\/p>\n\n<p>Go to Finder &gt; Preferences\u2026<\/p>\n\n<p><img src=\"\/assets\/img\/finder-preferences.png\" alt=\"\" \/><\/p>\n\n<p>Then select \u201cShow all filename extensions\u201d<\/p>\n\n<p><img src=\"\/assets\/img\/finder-preferences-show-filename-extensions.png\" alt=\"\" \/><\/p>\n\n<p>That\u2019s it!<\/p>","author":{"name":{}},"summary":"I like to see the file extensions in Finder. I had to look up how to do this. Here\u2019s how you do it:"},{"title":"Disabling Autocomplete In Atom","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2018-09-14\/disabling-autocomplete-in-atom","rel":"alternate","type":"text\/html","title":"Disabling Autocomplete In Atom"}},"published":"2018-09-14T00:00:00+00:00","updated":"2018-09-14T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2018-09-14\/disabling-autocomplete-in-atom","content":"<p>I use <a href=\"https:\/\/atom.io\/\">Atom<\/a>. It\u2019s kind of buggy, but I love it because of the customization options that you get with it. It definitely has some annoying bits though. I should contribute to the project, but until then I\u2019m finding some workarounds to make my programming life a bit less annoying.<\/p>\n\n<p>One thing about Atom that I\u2019m not particularly fond of is the autocomplete feature. Maybe some people find it useful, but I\u2019m not one of those people. When I\u2019m typing away (mostly when I\u2019m writing and not coding) and I hit \u201ctab\u201d or \u201center\u201d and some random autocomplete suggestion gets filled in, I find it pretty frustrating. It\u2019s even worse when the suggestion is a code snippet, and a few lines of random code are placed right by my cursor.<\/p>\n\n<p>So anyway I disabled it. Here\u2019s how:<\/p>\n\n<p>Go to the Atom Settings:\nAtom &gt; Preferences\u2026<\/p>\n\n<p><img src=\"\/assets\/img\/atom-preferences.png\" alt=\"\" \/><\/p>\n\n<p>Or just hit <code class=\"highlighter-rouge\">Cmd+,<\/code><\/p>\n\n<p>Then go to \u201cPackages\u201d:<\/p>\n\n<p><img src=\"\/assets\/img\/atom-packages.png\" alt=\"\" \/><\/p>\n\n<p>Then find \u201cautocomplete-plus\u201d and click \u201cSettings\u201d<\/p>\n\n<p><img src=\"\/assets\/img\/atom-autocomplete-plus-package.png\" alt=\"\" \/><\/p>\n\n<p>Then uncheck the \u201cShow Suggestions On Keystroke\u201d checkbox:<\/p>\n\n<p><img src=\"\/assets\/img\/atom-autocomplete-plus-show-suggestions-on-keystroke.png\" alt=\"\" \/><\/p>\n\n<p>That\u2019s it!<\/p>","author":{"name":{}},"summary":"I use Atom. It\u2019s kind of buggy, but I love it because of the customization options that you get with it. It definitely has some annoying bits though. I should contribute to the project, but until then I\u2019m finding some workarounds to make my programming life a bit less annoying."},{"title":"Adding A Remote Theme To Your GitHub Pages Site","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2018-09-14\/adding-a-remote-theme-to-your-github-pages-site","rel":"alternate","type":"text\/html","title":"Adding A Remote Theme To Your GitHub Pages Site"}},"published":"2018-09-14T00:00:00+00:00","updated":"2018-09-14T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2018-09-14\/adding-a-remote-theme-to-your-github-pages-site","content":"<p>I\u2019ll keep this one short and sweet since this process is pretty simple with <a href=\"https:\/\/jekyllrb.com\/\">Jekyll<\/a>. On this website, I\u2019m using the <a href=\"https:\/\/github.com\/chesterhow\/tale\">tale<\/a> theme from <a href=\"https:\/\/chester.how\/\">Chester How<\/a>. The readme on this project gives you a pretty clear path to getting this theme installed so <a href=\"https:\/\/github.com\/chesterhow\/tale#installation\">I\u2019ll leave you to that<\/a> if you want to use the same theme.<\/p>\n\n<p>There are a few options for installing themes with Jekyll. There\u2019s very complete documentation about Jekyll themes in <a href=\"https:\/\/jekyllrb.com\/docs\/themes\/\">the documentation<\/a>. There\u2019s also a very detailed write up on GitHub about <a href=\"https:\/\/help.github.com\/articles\/adding-a-jekyll-theme-to-your-github-pages-site\/\">installing a theme on your GitHub Pages site<\/a>. If you\u2019re wicked lazy like me then this post is for you!<\/p>\n\n<p>To install a remote-theme, you can add a line like this to your <code class=\"highlighter-rouge\">_config.yml<\/code> file and commit the change:<\/p>\n\n<p><code class=\"highlighter-rouge\">remote_theme: chesterhow\/tale<\/code><\/p>\n\n<p>Keep in mind though that doing <em>only<\/em> this will <em>only<\/em> work on your live GitHub Pages site. If you want to install a remote-theme and have the ability to preview the site locally, you\u2019ll need to add a couple additional things.<\/p>\n\n<p>First you\u2019ll have to add the following to your <code class=\"highlighter-rouge\">Gemfile<\/code>:<\/p>\n\n<p><code class=\"highlighter-rouge\">gem \"jekyll-remote-theme\"<\/code><\/p>\n\n<p>Then you need to add this to your <code class=\"highlighter-rouge\">_config.yml<\/code> file:<\/p>\n\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>plugins:\n  - jekyll-remote-theme\n<\/code><\/pre><\/div><\/div>\n\n<p>or if you already have a <code class=\"highlighter-rouge\">plugins<\/code> section, then just add the <code class=\"highlighter-rouge\">- jekyll-remote-theme<\/code> line under it.<\/p>\n\n<p>After that you\u2019ll have to run <code class=\"highlighter-rouge\">bundle<\/code> and then if you run <code class=\"highlighter-rouge\">bundle exec jekyll serve<\/code> you should see your new theme installed on your local site at <code class=\"highlighter-rouge\">localhost:4000<\/code>.<\/p>","author":{"name":{}},"summary":"I\u2019ll keep this one short and sweet since this process is pretty simple with Jekyll. On this website, I\u2019m using the tale theme from Chester How. The readme on this project gives you a pretty clear path to getting this theme installed so I\u2019ll leave you to that if you want to use the same theme."},{"title":"Getting Started With GitHub Pages","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2018-09-13\/getting-started-with-github-pages","rel":"alternate","type":"text\/html","title":"Getting Started With GitHub Pages"}},"published":"2018-09-13T00:00:00+00:00","updated":"2018-09-13T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2018-09-13\/getting-started-with-github-pages","content":"<p>I\u2019m hoping to document the things that I set up for this blog well enough so that anyone trying to do the same things can struggle less than I did. Plus, I like the idea of having a blog that contains meta documentation. You can do it too!<\/p>\n\n<p>I decided to use <a href=\"https:\/\/pages.github.com\/\">Github Pages<\/a> because it seemed pretty simple. It uses <a href=\"https:\/\/jekyllrb.com\/\">Jekyll<\/a> which is a static site generator so there\u2019s not a lot involved on the server-side. Also, GitHub Pages builds your site from a GitHub repository so you get the benefit of always having a backup of everything you do, and you can do cool things like allow your readers to submit pull requests for any mistakes that they find. There\u2019s a cool way to include \u201cImprove this page\u201d links (for pull request submissions) on every page automatically too.<\/p>\n\n<p>Another reason for using GitHub Pages was to get away from the maintenance involved in using WordPress\u2013the platform this site was previously built with. WordPress didn\u2019t really work for me because I didn\u2019t pay it enough attention to keep it updated or even running. My blog kept going down, and, after a while, I forgot to keep fixing it. It wasn\u2019t ideal for me. I\u2019m hoping that GitHub Pages will just work, and that it\u2019s simple enough to be able to come back to and be effective with after forgetting about it for some time.<\/p>\n\n<p>Anyway, enough talk about why. Let\u2019s get to the meat of this. My goal was to set up GitHub Pages and use a custom domain name so that I could use my old website\u2019s domain name. I.e. I wanted justpushbuttons.com to display my personal GitHub Pages site (which by default is jlvallelonga.github.io).<\/p>\n\n<p>In order to document the process, I used another domain name and a second GitHub account so that I could make sure I had everything correct. I was hoping that it would run smoothly the second time I did it, but that didn\u2019t really happen that way. I think I have it figured out now though. I\u2019ll try to document things well enough so that you can avoid the trouble that I ran into.<\/p>\n\n<p>So the domain that I used was notasecondlate.com. Get it? Like, my name is Justin. Sometimes people say \u201cJust-in-time\u201d and then laugh like I haven\u2019t heard that 1000 times before. So \u201cnot a second late\u201d is like\u2026 you see\u2026 ok whatever.<\/p>\n\n<p>I started by creating a GitHub account with the username \u201cnotasecondlate\u201d. That\u2019s pretty <a href=\"https:\/\/github.com\/\">straightforward<\/a>. Then I followed the instructions on the GitHub Pages homepage which are great so I\u2019ll leave you to reference that here:\n<a href=\"https:\/\/pages.github.com\/\">https:\/\/pages.github.com\/<\/a><\/p>\n\n<p>After following their instructions, my GitHub Pages site wasn\u2019t working:<\/p>\n\n<p><img src=\"\/assets\/img\/github-pages-404.png\" alt=\"\" \/><\/p>\n\n<p>but it said that it was working:<\/p>\n\n<p><img src=\"\/assets\/img\/settings-site-published-message.png\" alt=\"\" \/><\/p>\n\n<p>I found out that you can use a markdown file as your index page so, to troubleshoot, I renamed <code class=\"highlighter-rouge\">index.html<\/code> to <code class=\"highlighter-rouge\">index.md<\/code> and then I got this:<\/p>\n\n<p><img src=\"\/assets\/img\/notasecondlate-basic-theme.png\" alt=\"\" \/><\/p>\n\n<p>Ok, it was working, but I didn\u2019t really want that big blue header. So I renamed the file back to <code class=\"highlighter-rouge\">index.html<\/code> and now magically it worked:<\/p>\n\n<p><img src=\"\/assets\/img\/halo-world.png\" alt=\"\" \/><\/p>\n\n<p>Ok that was weird, but whatever. So if you happen to run into the same problem then you can try what I did. Apparently <a href=\"https:\/\/github.community\/t5\/GitHub-Pages\/index-html-not-working\/td-p\/1266\">I\u2019m not the only one with this issue either<\/a><\/p>\n\n<p>The site may have still been generating when I tried to visit the first time, so being patient is worth trying as well. I\u2019m not really sure how long you should expect GitHub to take to get your site running, but it didn\u2019t take long with the first site I set up\u2013maybe 10 minutes at the most.<\/p>\n\n<p>If you don\u2019t want a custom domain name, then that\u2019s all you need to do. You can start customizing your site. The <a href=\"https:\/\/jekyllrb.com\/docs\/step-by-step\/01-setup\/\">Jekyll step-by-step tutorial<\/a> helped me get up to speed on the basics. To set up a custom domain name, continue reading.<\/p>\n\n<p>So now I had my GitHub Pages site running at notasecondlate.github.io. To get notasecondlate.com pointed at this site (meaning visiting notasecondlate.com will load the GitHub Pages site), I just needed to add some DNS records. I bought notasecondlate.com from <a href=\"https:\/\/www.namecheap.com\/\">Namecheap.com<\/a>. They include DNS services when you register with them so I didn\u2019t have to use a different service for this.<\/p>\n\n<p>When I initially tried to set this up, something went wrong and the website wasn\u2019t loading or doing HTTPS redirects correctly or something. I didn\u2019t document it very well so I\u2019m fuzzy on details here. I think the best thing to do is to follow the steps carefully in order. When I did that, everything worked out.<\/p>\n\n<p>I mostly followed the steps on this page for <a href=\"https:\/\/www.namecheap.com\/support\/knowledgebase\/article.aspx\/9645\/2208\/how-do-i-link-my-domain-to-github-pages\">setting up a custom domain name with Namecheap<\/a><\/p>\n\n<p>The main difference was that instead of manually creating a CNAME file, I let GitHub do it for me. To make that happen, I went to the project settings on the GitHub repo:<\/p>\n\n<p><img src=\"\/assets\/img\/project-settings.png\" alt=\"\" \/><\/p>\n\n<p>Then in the GitHub Pages section, under \u201cCustom domain\u201d, I entered \u201cnotasecondlate.com\u201d and then clicked \u201cSave\u201d<\/p>\n\n<p><img src=\"\/assets\/img\/custom-domain.png\" alt=\"\" \/><\/p>\n\n<p>This adds the CNAME file to the GitHub repo for you.<\/p>\n\n<p>The next step is to add the DNS records with Namecheap\u2019s advanced DNS settings. You can follow steps 2 and 3 <a href=\"https:\/\/www.namecheap.com\/support\/knowledgebase\/article.aspx\/9645\/2208\/how-do-i-link-my-domain-to-github-pages\">on this Namecheap GitHub Pages guide<\/a> to get that working.<\/p>\n\n<p>I had 2 conflicting records that I removed (they were there by default):<\/p>\n\n<p><img src=\"\/assets\/img\/namecheap-conflicting-dns-records.png\" alt=\"\" \/><\/p>\n\n<p>So your DNS settings should look something like this when you\u2019re finished:<\/p>\n\n<p><img src=\"\/assets\/img\/namecheap-advanced-dns-records.png\" alt=\"\" \/><\/p>\n\n<p>The last thing to do is to enforce HTTPS (if it isn\u2019t already). Under the project settings for your repo, under the \u201cGitHub Pages\u201d section, check the \u201cEnforce HTTPS\u201d checkbox<\/p>\n\n<p><img src=\"\/assets\/img\/github-settings-enforce-https.png\" alt=\"\" \/><\/p>\n\n<p>You will have to wait some time before the DNS changes propagate, but come back in a day or two and your site should be up at the custom domain that you set up! Let me know in the comments if you have any questions or issues with the process of setting up your site. Or <a href=\"https:\/\/github.com\/jlvallelonga\/jlvallelonga.github.io\/edit\/master\/_posts\/2018-09-13-getting-started-with-github-pages.md\">submit a pull request<\/a> to suggest a change.<\/p>\n\n<p>Thanks for reading!<\/p>","author":{"name":{}},"summary":"I\u2019m hoping to document the things that I set up for this blog well enough so that anyone trying to do the same things can struggle less than I did. Plus, I like the idea of having a blog that contains meta documentation. You can do it too!"},{"title":"PCB Etching - Home Style","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-12-05\/pcb-etching-homestyle","rel":"alternate","type":"text\/html","title":"PCB Etching - Home Style"}},"published":"2013-12-05T00:00:00+00:00","updated":"2013-12-05T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-12-05\/pcb-etching-homestyle","content":"<p>The <a href=\"http:\/\/www.instructables.com\/id\/Stop-using-Ferric-Chloride-etchant!--A-better-etc\/\" target=\"_blank\">instructable<\/a> that I learned this from was pretty useful, but it left out a few things that I wanted to elaborate on.<\/p>\n\n<p>Supplies:<\/p>\n\n<ul>\n  <li>A blank PCB (\u201ccopper clad\u201d) to etch your circuit from (<a href=\"http:\/\/www.skycraftsurplus.com\/coppercladcircuitboard-18x12.aspx\" target=\"_blank\">here\u2019s<\/a> what I got but any copper clad will work. Note: avoid the 0.127\u2033, it\u2019s too thick to put some leads all the way through)<\/li>\n  <li>Sharpie (for etch resist)<\/li>\n  <li>Muriatic acid \u2013 20 Baume 31.45% (the 14.5% junk doesn\u2019t work). Also take care not to murder yourself with this stuff.<\/li>\n  <li>Hydrogen peroxide \u2013 3%<\/li>\n  <li>A glass container with a lid. Make sure that the lid is not airtight. If it is airtight, it can explode\u2026 acid everywhere\u2026 bad news.<\/li>\n  <li>Nerd goggles (safety first)<\/li>\n  <li>Particle respirator mask<\/li>\n  <li>Automotive rubbing compound (from the auto parts store)<\/li>\n<\/ul>\n\n<p><strong>Create the etching solution<\/strong><\/p>\n\n<p>The mixture is 2 parts peroxide to 1 part acid<\/p>\n\n<ol>\n  <li>Clean the glass container very well.<\/li>\n  <li>Put your goggles and mask on. Do not breathe in the acid fumes.<\/li>\n  <li>Pour the peroxide in first (\u201cdo what you oughta\u2026 add acid to water\u201d)<\/li>\n  <li>Pour the acid in slowly<\/li>\n  <li>Now you have the etching solution. The solution should be clear at this point.<\/li>\n<\/ol>\n\n<p><strong>Make your circuit<\/strong><\/p>\n\n<ol>\n  <li>Design your circuit layout on a piece of paper first. Make sure that the components will fit on the layout. You will have to drill holes for the through-hole components so make sure that you have room for these holes on the traces. (see image below)\n<img src=\"\/assets\/img\/leads-fit1.jpg\" alt=\"\" \/><\/li>\n  <li>Cut out a piece of copper clad that will fit the layout that you just designed.<\/li>\n  <li>Clean the copper clad with some automotive rubbing compound on a paper towel. This will smooth out some of the scratches on the copper.<\/li>\n  <li>Clean off all of the rubbing compound. You can wash the compound off with water. Be careful to only handle the circuit board by the edges after this to avoid getting the oils from your skin on the copper.<\/li>\n  <li>Tape the paper that you designed your circuit on to your piece of copper. This will serve as your guide when you are drilling the holes for the through-hole components.<\/li>\n  <li>And then\u2026 drill the holes for the through-hole components. When you\u2019re done take off the tape and paper. Use a bigger drill bit by hand to take the rough edges off of the copper around the holes.<\/li>\n  <li>Use the Sharpie to draw on the traces. This is where you want the copper to remain after etching. Essentially you are keeping the acid from eating the copper under the ink.<\/li>\n  <li>Let the ink dry for a while.<\/li>\n  <li>Put the board in the etchant solution to etch the board.<\/li>\n  <li>Wait until all of the visible copper is dissolved. You can wait a little longer once the visible copper is dissolved, but don\u2019t wait too long because the etchant might begin to eat under the traces.<\/li>\n  <li>Take the board out (I usually drill an extra hole to put a string through so that I can pull the board out without sticking my hand or something in there).<\/li>\n  <li>Wash off the board thoroughly being careful not to touch it until all of the acid has been completely rinsed off.<\/li>\n  <li>Dry off the board. Paper towels work.<\/li>\n  <li>Use acetone or lacquer thinner to clean off the etch resist. Make sure all of the etch resist is gone so that you won\u2019t have a hard time soldering.<\/li>\n  <li>Solder the parts in and you\u2019re finished!<\/li>\n<\/ol>\n\n<p><strong>references:<\/strong><\/p>\n\n<p><a href=\"http:\/\/www.instructables.com\/id\/Stop-using-Ferric-Chloride-etchant!--A-better-etc\/\" target=\"_blank\">http:\/\/www.instructables.com\/id\/Stop-using-Ferric-Chloride-etchant!\u2013A-better-etc\/<\/a><\/p>\n\n<p><a href=\"http:\/\/www.stefanv.com\/electronics\/etching.htm\" target=\"_blank\">http:\/\/www.stefanv.com\/electronics\/etching.htm<\/a><\/p>","author":{"name":{}},"summary":"The instructable that I learned this from was pretty useful, but it left out a few things that I wanted to elaborate on."},{"title":"My Robot","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-05-13\/my-robot","rel":"alternate","type":"text\/html","title":"My Robot"}},"published":"2013-05-13T00:00:00+00:00","updated":"2013-05-13T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-05-13\/my-robot","content":"<p>So I\u2019ve been working on a robot\u2026<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_complete.jpg\" alt=\"\" \/><\/p>\n\n<p>I\u2019ve succeeded at making it autonomous\u2026 kind of\u2026 well it works most of the time. Before about a week ago it was a big mess of wires. Then I etched a circuit board so that it wouldn\u2019t be a big mess of wires. Then i realized that I swapped the headers on the motor controller board\u2026 so again\u2026 it is a big mess of wires. To fix this I\u2019m going to make a patch board that swaps the headers again. Here\u2019s a video of it before the custom board was added (please excuse the crappy quality)<\/p>\n\n<iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/i_IALH4xBSE\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe>\n\n<p>As you can see in the video, an LED turns on when it sees something and reacts. This was more of a debugging feature, but it lets you know that it is seeing things and reacting accordingly.<\/p>\n\n<p>So anyway, there is a 180 degree servo in the front with a <a href=\"http:\/\/www.sparkfun.com\/products\/8502\" target=\"_blank\">ultrasonic range finder<\/a> mounted on it. This is the eyeball. It looks forward, right, and left for anything within a certain distance. If it finds anything close enough when it looks in one of those directions, then it reacts accordingly. If something is too close in front of it, it turns about 90 degrees to the left and continues onward. If it sees anything too close to the right or to the left, it turns a little left or a little right, respectively.<\/p>\n\n<p>Below is the custom PCB with no parts on it. I used muriatic acid and hydrogen peroxide to etch it (<a href=\"\/2013-12-05\/pcb-etching-homestyle\">more details on that process here<\/a>)<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_empty.jpg\" alt=\"custom board with almost no parts on it\" \/><\/p>\n\n<p>Here\u2019s the board with all the parts soldered in<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_full.jpg\" alt=\"Custom PCB with parts soldered in\" \/><\/p>\n\n<p>And here\u2019s the board on the robot. You can see how much of a mess it is because of my mistake with with headers. I was really hoping to avoid this, but I\u2019ll fix it with a patch board.<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_complete.jpg\" alt=\"\" \/><\/p>\n\n<p>I\u2019ve put headers on the board for my wireless receiver module (seen below). However, when I implemented control through the WiiChuck using this wireless module, it couldn\u2019t receive a signal after the bot started moving. Maybe I\u2019m getting noise on the lines because of the motors? I don\u2019t know. If anyone has an idea what the problem is then let me know.<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_wireless_rx.jpg\" alt=\"\" \/><\/p>\n\n<p>The next step is to get the robot to use the gap counters to map out the dimensions of the room it is in. Essentially I\u2019ll figure out how far the robot goes for one full rotation of the tracks. Then I\u2019ll have to figure out angles and whatever else\u2026 should be fun. (<a href=\"\/2013-05-12\/infrared-gap-counter\">more on the gap counter<\/a>)<\/p>\n\n<p><img src=\"\/assets\/img\/robot_board_gap_counter.jpg\" alt=\"\" \/><\/p>","author":{"name":{}},"summary":"So I\u2019ve been working on a robot\u2026"},{"title":"Infrared Gap Counter","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-05-12\/infrared-gap-counter","rel":"alternate","type":"text\/html","title":"Infrared Gap Counter"}},"published":"2013-05-12T00:00:00+00:00","updated":"2013-05-12T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-05-12\/infrared-gap-counter","content":"<p><img src=\"\/assets\/img\/large_tank_treads.jpg\" alt=\"\" \/> I wanted to enable my robot with a sense of distance. Luckily my robot has build in distance markers in its <a href=\"http:\/\/www.sparkfun.com\/products\/321\" target=\"_blank\">tank treads<\/a>. There are little gaps in the treads which I can put <a href=\"http:\/\/www.sparkfun.com\/products\/241\" target=\"_blank\">infrared emitters and detectors<\/a> on either side of. This will allow my arduino to count the number of gaps that have passed by while the robot is moving.<\/p>\n\n<p>The number of gaps is a constant and so I will be able to count the number of revolutions of the track and measure the distance that the robot has traveled. Furthermore, by putting a gap counter (an emitter and a detector) on both the right and left tracks I will be able to calculate the angle that the robot has turned when it does so.<\/p>\n\n<p>I\u2019ve developed a proof of concept and tested it with a piece of track that I had leftover.<\/p>\n\n<p><img src=\"\/assets\/img\/large_infrared_gap_detector.jpg\" alt=\"\" \/>\nThe electronics are pretty simple. The infrared emitter is simply an LED that emits infrared light instead of visible light. In my concept, I used a regular red LED because the detector was just as able to pick up on that as it was on the infrared LED (and because I am a little short on infrared LEDs).<\/p>\n\n<p>The infrared detector works like a transistor except instead of using a base to trigger the flow of electrons from the collector to the emitter it uses infrared light. So when you shine infrared light (or a red LED in my case) on the detector it allows electricity to flow from the collector to the emitter. Pretty simple.\n<img src=\"\/assets\/img\/ir_schematic.gif\" alt=\"source: http:\/\/www.reconnsworld.com\/ir_ultrasonic_basicirdetectemit.html\" \/>\nHere\u2019s the schematic for the circuit that I used. Again, when there is infrared light shining on the detector (Q1), it allows electricity to flow from the collector (no arrow) to the emitter (arrow). When electricity is flowing through the detector, the electrons do not want to go to the output since there is greater resistance there, so most of them go through the detector. When you block the infrared light from getting to the detector, the detector doesn\u2019t allow electricity to flow through it and so most of the electrons go through the output. I tied the output to an analog input on my arduino (pin 4) so that I would be able to tell if the infrared light was being blocked or not. A higher reading (voltage level) on pin 4 would mean there is no infrared light shining on the detector, and a lower reading on pin 4 would mean that there is light shining on the detector.<\/p>\n\n<p>Now that you understand that (assuming that made any sense to you), the rest is pretty simple. Below is the arduino code for my proof of concept. Essentially it increments a counter every time it senses a gap. When it senses a gap it waits until the gap is over to start looking for another one.<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"kt\">int<\/span> <span class=\"n\">sensorPin<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">4<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">counter<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">setup<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">begin<\/span><span class=\"p\">(<\/span><span class=\"mi\">9600<\/span><span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">loop<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n  <span class=\"kt\">int<\/span> <span class=\"n\">sensorValue<\/span> <span class=\"o\">=<\/span> <span class=\"n\">analogRead<\/span><span class=\"p\">(<\/span><span class=\"n\">sensorPin<\/span><span class=\"p\">);<\/span>\n  <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">sensorValue<\/span> <span class=\"o\">&lt;<\/span> <span class=\"mi\">400<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>     <span class=\"c1\">\/\/if there is a gap\n<\/span>     <span class=\"n\">counter<\/span><span class=\"o\">++<\/span><span class=\"p\">;<\/span>                <span class=\"c1\">\/\/increment the counter\n<\/span>     <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"s\">\"counter : \"<\/span><span class=\"p\">);<\/span>\n     <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">println<\/span><span class=\"p\">(<\/span><span class=\"n\">counter<\/span><span class=\"p\">);<\/span>\n     <span class=\"n\">boolean<\/span> <span class=\"n\">low<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">true<\/span><span class=\"p\">;<\/span>\n     <span class=\"k\">while<\/span> <span class=\"p\">(<\/span><span class=\"n\">low<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>   <span class=\"c1\">\/\/wait until the end of the gap to reset\n<\/span>       <span class=\"n\">sensorValue<\/span> <span class=\"o\">=<\/span> <span class=\"n\">analogRead<\/span><span class=\"p\">(<\/span><span class=\"n\">sensorPin<\/span><span class=\"p\">);<\/span>\n       <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">sensorValue<\/span> <span class=\"o\">&gt;<\/span> <span class=\"mi\">400<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n         <span class=\"n\">low<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">false<\/span><span class=\"p\">;<\/span>\n      <span class=\"p\">}<\/span>\n    <span class=\"p\">}<\/span>\n  <span class=\"p\">}<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>Here is a video of this idea in action. I\u2019ve set up a gap counter on the tank treads so that I can measure the distance that the robot has traveled. The code I have running rotates the tank tread until 50 gaps have gone by (all the way around). I\u2019ve marked the starting point with a white dot. It\u2019s a little hard to see but you get the idea.<\/p>\n\n<iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/Jw4QbSKPI40\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe>","author":{"name":{}},"summary":"I wanted to enable my robot with a sense of distance. Luckily my robot has build in distance markers in its tank treads. There are little gaps in the treads which I can put infrared emitters and detectors on either side of. This will allow my arduino to count the number of gaps that have passed by while the robot is moving."},{"title":"GPS Clock using ArduPilot and EM-406","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-05-11\/gps-clock-using-ardupilot-and-em-406","rel":"alternate","type":"text\/html","title":"GPS Clock using ArduPilot and EM-406"}},"published":"2013-05-11T00:00:00+00:00","updated":"2013-05-11T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-05-11\/gps-clock-using-ardupilot-and-em-406","content":"<p>So we got tired of not being able to see what time it was when we were watching movies\/shows on Netflix. We could have just bought a clock, but where\u2019s the fun in that? I had an EM-406 GPS module and an ArduPilot lying around, and I heard about <a href=\"http:\/\/www.sparkfun.com\/tutorials\/47\" target=\"_blank\">Sparkfun\u2019s 12ft GPS Wall Clock<\/a> so I figured I would give it a try.<\/p>\n\n<p>I had built a clock before just using an Arduino board, but the clock would get out of sync after a couple of days because of the little bit of processing time that was taken by the Arduino. So I put that aside and was planning on getting a <a href=\"http:\/\/www.sparkfun.com\/products\/10079\" target=\"_blank\">Real Time Clock DS3234 IC from Sparkfun<\/a>, but the chip is a bit expensive, hard to solder, and the <a href=\"http:\/\/www.sparkfun.com\/products\/10160\" target=\"_blank\">breakout board<\/a> is even more expensive. Not that I couldn\u2019t afford to spend $20 on this, I just had <a href=\"\/2013-05-13\/my-robot\">more exciting projects<\/a> on my mind so it went to the back burner.<\/p>\n\n<p>When I heard that you could use a GPS module to get very accurate UTC, I was like \u201cAllllllrighty then!\u201d and I started working. I had a little trouble programming the ArduPilot until I realized that you have to connect a power supply other than the FTDI cable to power the MCU. Once I did that, I got a simple blinky sketch running, and then I started working with the EM-406 module. When the EM-406 module has a signal, it\u2019s LED blinks. Once it\u2019s blinking you can get UTC time from it using an NMEA library, do some funky magic and \u201cbadda bing, badda boom\u201d you\u2019ve got a clock. See my code below:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"cp\">#include &lt;wprogram.h&gt;\n#include &lt;nmea.h&gt;\n#include &lt;SoftwareSerial.h&gt;\n<\/span>\n<span class=\"cp\">#define txPin 6  \/\/to the RX pin\n#define rxPin 12  \/\/not used\n<\/span><span class=\"n\">SoftwareSerial<\/span> <span class=\"n\">mySerial<\/span> <span class=\"o\">=<\/span>  <span class=\"n\">SoftwareSerial<\/span><span class=\"p\">(<\/span><span class=\"n\">rxPin<\/span><span class=\"p\">,<\/span> <span class=\"n\">txPin<\/span><span class=\"p\">);<\/span>\n\n<span class=\"n\">NMEA<\/span> <span class=\"n\">gps<\/span><span class=\"p\">(<\/span><span class=\"n\">GPRMC<\/span><span class=\"p\">);<\/span>  <span class=\"c1\">\/\/ GPS data connection to GPRMC sentence type\n<\/span><span class=\"kt\">float<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">;<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">setup<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">begin<\/span><span class=\"p\">(<\/span><span class=\"mi\">4800<\/span><span class=\"p\">);<\/span>\n\n   <span class=\"n\">pinMode<\/span><span class=\"p\">(<\/span><span class=\"n\">txPin<\/span><span class=\"p\">,<\/span> <span class=\"n\">OUTPUT<\/span><span class=\"p\">);<\/span>\n   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">begin<\/span><span class=\"p\">(<\/span><span class=\"mi\">9600<\/span><span class=\"p\">);<\/span>\n   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x76<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ Reset Command\n<\/span>\n   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x7A<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ Command byte\n<\/span>   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x05<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ bright display\n<\/span>\n   <span class=\"c1\">\/\/display the colon\n<\/span>   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x77<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ Command byte\n<\/span>   <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x10<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ colon\n<\/span>\n   <span class=\"n\">demo<\/span><span class=\"p\">();<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">loop<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n  <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">available<\/span><span class=\"p\">()<\/span> <span class=\"o\">&gt;<\/span> <span class=\"mi\">0<\/span> <span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"c1\">\/\/ read incoming character from GPS\n<\/span>    <span class=\"kt\">char<\/span> <span class=\"n\">c<\/span> <span class=\"o\">=<\/span> <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">read<\/span><span class=\"p\">();<\/span>\n\n    <span class=\"c1\">\/\/ check if the character completes a valid GPS sentence\n<\/span>    <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">gps<\/span><span class=\"p\">.<\/span><span class=\"n\">decode<\/span><span class=\"p\">(<\/span><span class=\"n\">c<\/span><span class=\"p\">))<\/span> <span class=\"p\">{<\/span>\n      <span class=\"c1\">\/\/ check if GPS positioning was active\n<\/span>      <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">gps<\/span><span class=\"p\">.<\/span><span class=\"n\">gprmc_status<\/span><span class=\"p\">()<\/span> <span class=\"o\">==<\/span> <span class=\"sc\">'A'<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n        <span class=\"n\">gpsTime<\/span> <span class=\"o\">=<\/span> <span class=\"kt\">int<\/span><span class=\"p\">(<\/span><span class=\"n\">gps<\/span><span class=\"p\">.<\/span><span class=\"n\">gprmc_utc<\/span><span class=\"p\">()<\/span> <span class=\"o\">\/<\/span> <span class=\"mi\">100<\/span><span class=\"p\">)<\/span> <span class=\"o\">-<\/span> <span class=\"mi\">600<\/span><span class=\"p\">;<\/span>\n        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">gpsTime<\/span> <span class=\"o\">&lt;<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>           <span class=\"n\">gpsTime<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">2400<\/span> <span class=\"o\">+<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">;<\/span>         <span class=\"p\">}<\/span>         <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">gpsTime<\/span> <span class=\"o\">&gt;=<\/span> <span class=\"mi\">1300<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n          <span class=\"n\">gpsTime<\/span> <span class=\"o\">=<\/span> <span class=\"n\">gpsTime<\/span> <span class=\"o\">-<\/span> <span class=\"mi\">1200<\/span><span class=\"p\">;<\/span>\n        <span class=\"p\">}<\/span>\n        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">1000<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">100<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">10<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n        <span class=\"p\">}<\/span>\n        <span class=\"k\">else<\/span> <span class=\"p\">{<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">1000<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">100<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">10<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n          <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"n\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span> <span class=\"n\">gpsTime<\/span><span class=\"p\">),<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n        <span class=\"p\">}<\/span>\n      <span class=\"p\">}<\/span>\n    <span class=\"p\">}<\/span>\n  <span class=\"p\">}<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"kt\">int<\/span> <span class=\"nf\">getPlace<\/span><span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">place<\/span><span class=\"p\">,<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">startingValue<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">startingValue<\/span> <span class=\"o\">=<\/span> <span class=\"n\">startingValue<\/span> <span class=\"o\">-<\/span> <span class=\"p\">(<\/span><span class=\"n\">startingValue<\/span> <span class=\"o\">%<\/span> <span class=\"n\">place<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">startingValue<\/span> <span class=\"o\">=<\/span> <span class=\"n\">startingValue<\/span> <span class=\"o\">\/<\/span> <span class=\"n\">place<\/span><span class=\"p\">;<\/span>\n  <span class=\"kt\">int<\/span> <span class=\"n\">placeValue<\/span> <span class=\"o\">=<\/span> <span class=\"n\">startingValue<\/span> <span class=\"o\">%<\/span> <span class=\"mi\">10<\/span><span class=\"p\">;<\/span>\n  <span class=\"k\">return<\/span> <span class=\"n\">placeValue<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">demo<\/span><span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">delay<\/span><span class=\"p\">(<\/span><span class=\"mi\">80<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mi\">8<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">delay<\/span><span class=\"p\">(<\/span><span class=\"mi\">80<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mi\">8<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">delay<\/span><span class=\"p\">(<\/span><span class=\"mi\">80<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mi\">8<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">delay<\/span><span class=\"p\">(<\/span><span class=\"mi\">80<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mh\">0x78<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n  <span class=\"n\">mySerial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"mi\">8<\/span><span class=\"p\">,<\/span><span class=\"n\">BYTE<\/span><span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p><strong>Pictures!<\/strong>\n<img src=\"\/assets\/img\/clock-front.jpg\" alt=\"The front of it\" \/>\n<img src=\"\/assets\/img\/clock-power.jpg\" alt=\"The power source\" \/>\n<img src=\"\/assets\/img\/clock-guts.jpg\" alt=\"The innards\" \/>\n<img src=\"\/assets\/img\/clock-working.jpg\" alt=\"Action shot!\" \/><\/p>","author":{"name":{}},"summary":"So we got tired of not being able to see what time it was when we were watching movies\/shows on Netflix. We could have just bought a clock, but where\u2019s the fun in that? I had an EM-406 GPS module and an ArduPilot lying around, and I heard about Sparkfun\u2019s 12ft GPS Wall Clock so I figured I would give it a try."},{"title":"Using the Pocket Progmammer with ATMega328p","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-05-10\/using-pocket-programmer-with-atmega328p","rel":"alternate","type":"text\/html","title":"Using the Pocket Progmammer with ATMega328p"}},"published":"2013-05-10T00:00:00+00:00","updated":"2013-05-10T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-05-10\/using-pocket-programmer-with-atmega328p","content":"<p><img src=\"\/assets\/img\/atmega328.jpg\" alt=\"\" \/>\nI thought that I would have to learn AVR code in order to program my ATMega328P micro. Then I got to reading on the arduino.cc website and found out that by changing a setting in the arduino software\u2019s preferences.txt file I could simply use the arduino software and arduino code for programming my chip.<\/p>\n\n<p><strong>Parts I used:<\/strong><\/p>\n\n<ul>\n  <li><a href=\"http:\/\/www.sparkfun.com\/products\/9825\" target=\"_blank\">Pocket AVR Programmer<\/a><\/li>\n  <li><a href=\"http:\/\/www.sparkfun.com\/products\/9217\" target=\"_blank\">ATMega328P with arduino bootloader<\/a><\/li>\n  <li><a href=\"http:\/\/www.sparkfun.com\/products\/536\" target=\"_blank\">16MHz Crystal<\/a><\/li>\n<\/ul>\n\n<p>Follow the instructions in <a href=\"http:\/\/www.sparkfun.com\/tutorials\/93\" target=\"_blank\">this tutorial<\/a> to get your breadboard set up.<\/p>\n\n<p>Make sure to put a 16MHz crystal in your circuit if you are using the ATMega328P with the arduino bootloader (between pins 9 and 10 on the ATMega). I spent a while trying to figure out that I just needed to put in a crystal because the micro had been preconfigured to use a 16MHz crystal instead of the internal oscillator.<\/p>\n\n<p>K ready go.<\/p>\n\n<ol>\n  <li>Make sure your arduino software isn\u2019t open.<\/li>\n  <li>Change the preferences file. Located here: C:\\Documents and Settings&lt;USER&gt;\\Application Data\\Arduino\\preferences.txt<\/li>\n  <li>Change this line: <code class=\"highlighter-rouge\">upload.using=bootloader<\/code><\/li>\n  <li>To look like this: <code class=\"highlighter-rouge\">upload.using=usbtinyisp<\/code><\/li>\n  <li>Change \u201cusbtinyisp\u201d to match whatever programmer you are using. A list of values for this are in programmers.txt under your arduino install location:\n<code class=\"highlighter-rouge\">...arduino-0022\\hardware\\arduino\\programmers.txt<\/code>\nRead more about this <a href=\"http:\/\/arduino.cc\/en\/Hacking\/Programmer\" target=\"_blank\">here<\/a>.\n<img src=\"\/assets\/img\/preferences_file.jpg\" alt=\"\" \/><\/li>\n  <li>Save preferences.txt<\/li>\n  <li>Now write some arduino code. I started with blinking an LED to make sure I had it right. Then I uploaded some code to turn a servo. Use <a href=\"http:\/\/tinkerlog.com\/2009\/06\/18\/microcontroller-cheat-sheet\/\" target=\"_blank\">this awesome page<\/a> to figure out how the pins from your arduino translate to pins on the ATMega.<\/li>\n  <li>When you have your code ready to upload, use the Tools&gt;Board menu to select a board with the same microcontroller that you\u2019re using. I selected the Arduino Uno because I know it uses the ATMega328.\n<img src=\"\/assets\/img\/choose_board.jpg\" alt=\"\" \/><\/li>\n  <li>Now all you have to do is press the upload button in the arduino software and your code will upload to the ATMega and run.<\/li>\n<\/ol>\n\n<p>Here\u2019s a video of the action. I\u2019ve hooked up a servo to my breadboard (arduino pin 9 = ATMega pin 15), and uploaded some code to turn it clockwise and counterclockwise.<\/p>\n\n<iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/IGJm8JtelSc\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe>","author":{"name":{}},"summary":"I thought that I would have to learn AVR code in order to program my ATMega328P micro. Then I got to reading on the arduino.cc website and found out that by changing a setting in the arduino software\u2019s preferences.txt file I could simply use the arduino software and arduino code for programming my chip."},{"title":"Raspberry Pi and Arduino: Serial Communication Over GPIO pins","link":{"@attributes":{"href":"https:\/\/justpushbuttons.com\/2013-01-19\/raspberry-pi-and-arduino-serial-communication-over-gpio","rel":"alternate","type":"text\/html","title":"Raspberry Pi and Arduino: Serial Communication Over GPIO pins"}},"published":"2013-01-19T00:00:00+00:00","updated":"2013-01-19T00:00:00+00:00","id":"https:\/\/justpushbuttons.com\/2013-01-19\/raspberry-pi-and-arduino-serial-communication-over-gpio","content":"<p><img src=\"\/assets\/img\/rPi-with-portable-DVD-player.jpg\" alt=\"Just a picture of the Raspberry Pi running\" \/><\/p>\n\n<p>I recently received a Raspberry Pi from a friend and I wanted to see if I could tie it to one of my Arduino boards without using a USB cable.\nThe <a href=\"http:\/\/www.raspberrypi.org\/phpBB3\/viewtopic.php?f=37&amp;t=22736\" target=\"_blank\">tutorial<\/a>s I <a href=\"http:\/\/codeandlife.com\/2012\/07\/29\/arduino-and-raspberry-pi-serial-communication\/\" target=\"_blank\">found<\/a> were helpful and relatively simple but were missing some details that I thought would be helpful.\nSo I\u2019ve decided to make a (hopefully) more simple tutorial to get people up and running with serial on the Raspberry Pi\u2019s GPIO pins.<\/p>\n\n<p>Required hardware:<\/p>\n\n<ul>\n  <li>an <a href=\"http:\/\/adafruit.com\/products\/50\" target=\"_blank\">Arduino<\/a><\/li>\n  <li><a href=\"https:\/\/www.sparkfun.com\/products\/8745\" target=\"_blank\">logic level converter<\/a> (or you can make this with transistors)<\/li>\n  <li>a <a href=\"http:\/\/adafruit.com\/products\/998?gclid=CMjOvLCY9bQCFQpgMgodjWIAsw\" target=\"_blank\">Raspberry Pi<\/a><\/li>\n  <li>some wires<\/li>\n  <li>and a breadboard<\/li>\n<\/ul>\n\n<p>The first thing is to get your Raspberry Pi up and running.\nI used <a href=\"http:\/\/elinux.org\/RPi_Easy_SD_Card_Setup\" target=\"_blank\">this wiki page<\/a> to get an operating system (<a href=\"http:\/\/www.raspberrypi.org\/downloads\" target=\"_blank\">Raspian Wheezy<\/a> for me) installed in my SD card. I had to use the \u201cflashnul\u201d software because the Win32DiskImager software used in the \u201ceasy way\u201d wouldn\u2019t recognize my SD card.<\/p>\n\n<p>Once that is done you can plug a keyboard and a monitor into your Raspberry Pi (you don\u2019t need a mouse for what we\u2019re doing). I used the yellow composite cable port to connect my Pi to an old portable DVD player. Plug the power cable (micro USB) into the Raspberry Pi. When it starts for the first time you will see a configuration settings screen. I followed the steps in <a href=\"http:\/\/www.engadget.com\/2012\/09\/04\/raspberry-pi-getting-started-guide-how-to\/\" target=\"_blank\">this tutorial<\/a> to get mine setup. Additionally, I enabled the SSH server because I didn\u2019t want to have so many things plugged in when using my Pi. When you\u2019ve finished with the configuration and you\u2019ve rebooted your Pi it will present you with a login screen.  If you had plugged in an ethernet cable to your Pi you should have seen an IP address during boot. I use this IP address to SSH into my Pi from my desktop computer. The login name is \u201cpi\u201d and the password is the one you setup during configuration. Log in to your Pi (I logged in via SSH).<\/p>\n\n<p>Note: don\u2019t run the \u201cstartx\u201d command after you log in. You can do everything you need for this tutorial from the command line.<\/p>\n\n<p>Now you can begin installing the junk you need to get going with serial over GPIO.<\/p>\n\n<p>The first thing I did was update the Pi. press \u201cy\u201d when prompted: <code class=\"highlighter-rouge\">sudo apt-get update &amp;&amp; sudo apt-get upgrade<\/code><\/p>\n\n<p>The next thing is to get Vim installed: <code class=\"highlighter-rouge\">sudo apt-get install vim<\/code><\/p>\n\n<p>Now for the actual serial over GPIO configuration\u2026<\/p>\n\n<p>Use vim to comment (#) this line out of \/etc\/inittab (it was the last line in my inittab file):<\/p>\n\n<p><code class=\"highlighter-rouge\">T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100<\/code><\/p>\n\n<p>so that line becomes:<\/p>\n\n<p><code class=\"highlighter-rouge\">#T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100<\/code><\/p>\n\n<p>I think I rebooted at this point although I\u2019m not sure it matters: <code class=\"highlighter-rouge\">sudo reboot<\/code><\/p>\n\n<p>Then use vim to remove this section from \/boot\/cmdline.txt<\/p>\n\n<p><code class=\"highlighter-rouge\">console=ttyAMA0,115200 kgdboc=ttyAMA0,115200<\/code><\/p>\n\n<p>Be careful to remove only that.<\/p>\n\n<p>Reboot your raspberry pi: <code class=\"highlighter-rouge\">sudo reboot<\/code><\/p>\n\n<p>Then install minicom: <code class=\"highlighter-rouge\">sudo apt-get install minicom<\/code><\/p>\n\n<p>Now your Raspberry Pi is ready software-wise.<\/p>\n\n<p>Load this sketch onto your Arduino:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"n\">byte<\/span> <span class=\"n\">num<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">setup<\/span><span class=\"p\">()<\/span>\n<span class=\"p\">{<\/span>\n  <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">begin<\/span><span class=\"p\">(<\/span><span class=\"mi\">9600<\/span><span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"kt\">void<\/span> <span class=\"nf\">loop<\/span><span class=\"p\">()<\/span>\n<span class=\"p\">{<\/span>\n  <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">available<\/span><span class=\"p\">())<\/span>\n  <span class=\"p\">{<\/span>\n    <span class=\"n\">num<\/span> <span class=\"o\">=<\/span> <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">read<\/span><span class=\"p\">();<\/span>\n    <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">print<\/span><span class=\"p\">(<\/span><span class=\"s\">\"character recieved: \"<\/span><span class=\"p\">);<\/span>\n    <span class=\"n\">Serial<\/span><span class=\"p\">.<\/span><span class=\"n\">println<\/span><span class=\"p\">(<\/span><span class=\"n\">num<\/span><span class=\"p\">,<\/span> <span class=\"n\">DEC<\/span><span class=\"p\">);<\/span>\n  <span class=\"p\">}<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>After that\u2019s been loaded onto the Arduino, turn them both off and wire them up according to this diagram:<\/p>\n\n<p><img src=\"\/assets\/img\/wiring-arduino-to-rpi.png\" alt=\"created with draw.io\" \/><\/p>\n\n<p>Also this might help:<\/p>\n\n<p><img src=\"https:\/\/elinux.org\/images\/2\/2a\/GPIOs.png\" alt=\"\" \/><\/p>\n\n<p>Additionally, there are some pictures of my wiring setup at the bottom of the page.<\/p>\n\n<p>Double check your wiring. I\u2019ve heard that you can break the crap out of your Raspberry Pi if you do it wrong.<\/p>\n\n<p>I\u2019m not sure the order matters, but turn on your Raspberry Pi and then turn on your Arduino. Login to your Pi and enter the following command to connect to the Arduino:<\/p>\n\n<p><code class=\"highlighter-rouge\">minicom -b 9600 -o -D \/dev\/ttyAMA0<\/code><\/p>\n\n<p>Now whatever you type is sent to the Arduino and the Arduino responds with the decimal format of the character that it received (see <a href=\"http:\/\/www.asciitable.com\/\" target=\"_blank\">asciitable.com<\/a>)<\/p>\n\n<p><img src=\"\/assets\/img\/minicom-screenshot.jpg\" alt=\"\" \/><\/p>\n\n<p>Also, to get out of minicom do: <code class=\"highlighter-rouge\">ctrl-a q<\/code><\/p>\n\n<p>Success! Your Raspberry Pi is now communicating with your Arduino over the GPIO pins.<\/p>\n\n<p>This might be useful for testing, but in order to do something more useful you might want to communicate with the Arduino using Python.<\/p>\n\n<p>Exit out of  minicom: <code class=\"highlighter-rouge\">ctrl-a q<\/code><\/p>\n\n<p>Run this command to install the necessary python serial library: <code class=\"highlighter-rouge\">sudo apt-get install python-serial<\/code><\/p>\n\n<p>Then you can write a python program like this to send data to the Arduino over the serial line:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-python\" data-lang=\"python\"><span class=\"kn\">import<\/span> <span class=\"nn\">serial<\/span>\n<span class=\"n\">ser<\/span> <span class=\"o\">=<\/span> <span class=\"n\">serial<\/span><span class=\"o\">.<\/span><span class=\"n\">Serial<\/span><span class=\"p\">(<\/span><span class=\"s\">'\/dev\/ttyAMA0'<\/span><span class=\"p\">,<\/span> <span class=\"mi\">9600<\/span><span class=\"p\">,<\/span> <span class=\"n\">timeout<\/span><span class=\"o\">=<\/span><span class=\"mi\">1<\/span><span class=\"p\">)<\/span>\n<span class=\"n\">ser<\/span><span class=\"o\">.<\/span><span class=\"nb\">open<\/span><span class=\"p\">()<\/span>\n\n<span class=\"n\">ser<\/span><span class=\"o\">.<\/span><span class=\"n\">write<\/span><span class=\"p\">(<\/span><span class=\"s\">\"testing\"<\/span><span class=\"p\">)<\/span>\n<span class=\"k\">try<\/span><span class=\"p\">:<\/span>\n        <span class=\"k\">while<\/span> <span class=\"mi\">1<\/span><span class=\"p\">:<\/span>\n                <span class=\"n\">response<\/span> <span class=\"o\">=<\/span> <span class=\"n\">ser<\/span><span class=\"o\">.<\/span><span class=\"n\">readline<\/span><span class=\"p\">()<\/span>\n                <span class=\"k\">print<\/span> <span class=\"n\">response<\/span>\n<span class=\"k\">except<\/span> <span class=\"nb\">KeyboardInterrupt<\/span><span class=\"p\">:<\/span>\n        <span class=\"n\">ser<\/span><span class=\"o\">.<\/span><span class=\"n\">close<\/span><span class=\"p\">()<\/span><\/code><\/pre><\/figure>\n\n<p>Run the program with: <code class=\"highlighter-rouge\">python &lt;program file name&gt;<\/code><\/p>\n\n<p>And your output should look something like this:<\/p>\n\n<p><img src=\"\/assets\/img\/python-serial-program-output.jpg\" alt=\"\" \/><\/p>\n\n<p>press ctrl-c to exit the program.<\/p>\n\n<p>Well that\u2019s all for now. Have fun and let me know in the comments if you have any questions.<\/p>\n\n<p>Some pictures of the process:<\/p>\n\n<p><img src=\"\/assets\/img\/wiring-all.jpg\" alt=\"the full setup\" \/><\/p>\n\n<p><img src=\"\/assets\/img\/wiring-rPi.jpg\" alt=\"Raspberry Pi wiring\" \/><\/p>\n\n<p><img src=\"\/assets\/img\/wiring-arduino.jpg\" alt=\"Arduino wiring\" \/><\/p>\n\n<p><img src=\"\/assets\/img\/wiring-breadboard.jpg\" alt=\"Breadboard wiring with Logic Level Converter\" \/><\/p>","author":{"name":{}},"summary":{"@attributes":{"type":"html"}}}]}